qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
84,243
<p>I am developing a website that relies much on XML data. The web site has an interface where user can update data. The data provided by user will be updated to the respective XML file. However, the changes is not reflected until after 1 or 2 minutes.</p> <p>Anyone knows how to force the browser to load the latest XML file immediately?</p>
[ { "answer_id": 84351, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 2, "selected": false, "text": "Cache-Control: no-cache" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
84,263
<p>I'm designing a web site navigation hierarchy. It's a tree of nodes.</p> <p>Most nodes are pages. Some nodes are links (think shortcuts in Windows).</p> <p>Most pages hold HTML content. Some execute code.</p> <p>I'd like to represent these as this collection of classes and abstract (MustInherit) classes&hellip;</p> <p><img src="https://i.stack.imgur.com/0gNAy.gif" alt="class diagram"></p> <p>This is the database table where I'm going to store all this&hellip;</p> <p><a href="http://img178.imageshack.us/img178/8573/nodetablefm8.gif" rel="nofollow noreferrer">database table http://img178.imageshack.us/img178/8573/nodetablefm8.gif</a></p> <p>Here's where I'm stumped. PageNodes may or may not be roots.</p> <p>How should I handle the root class?</p> <p><img src="https://i.stack.imgur.com/1stKR.gif" alt="class diagram"></p> <p>I don't want to have to have all four of&hellip;</p> <ul> <li>HtmlPageNode</li> <li>CodePageNode</li> <li>Html<strong>Root</strong>PageNode</li> <li>Code<strong>Root</strong>PageNode</li> </ul> <p>I want the HtmlPageNode and CodePageNode classes to inherit <em>either</em> from PageNode or else from RootPageNode. Is that possible?</p> <hr> <p>Clarification: There are multiple root nodes and roots may have parent nodes. Each is the root of only a sub-tree that has distinct styling. Think of different, color-coded departments. (Perhaps root is a poor name choice. Suggestions?)</p> <hr> <p>Update: Regarding the "Root" name...<br> I've asked: <a href="https://stackoverflow.com/questions/86790/is-there-a-specific-name-for-the-node-that-coresponds-to-a-subtree">Is there a specific name for the node that coresponds to a subtree?</a></p>
[ { "answer_id": 84336, "author": "Sunny Milenov", "author_id": 8220, "author_profile": "https://Stackoverflow.com/users/8220", "pm_score": 1, "selected": false, "text": "class Node\n{\n private bool isRootNode;\n public bool IsRootNode;\n\n private StylingData stylingData;\n public StylingData StylingData\n {\n set\n {\n if (this.IsRootNode)\n this.stylingData = value;\n else\n throw new ApplicationException(\"The node is not root.\");\n }\n get\n {\n if (this.IsRootNode)\n return this.stylingData;\n else\n return this.parent.StylingData;\n }\n }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
84,278
<p>How do I use <code>RelativeSource</code> with WPF bindings and what are the different use-cases?</p>
[ { "answer_id": 84314, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 5, "selected": false, "text": "<Binding RelativeSource=\"{RelativeSource TemplatedParent}\"/>\n" }, { "answer_id": 84317, "author": "Abe Heidebrecht", "author_id": 9268, "author_profile": "https://Stackoverflow.com/users/9268", "pm_score": 11, "selected": true, "text": "{Binding Path=PathToProperty, RelativeSource={RelativeSource Self}}\n" }, { "answer_id": 605695, "author": "Drew Noakes", "author_id": 24874, "author_profile": "https://Stackoverflow.com/users/24874", "pm_score": 7, "selected": false, "text": "Binding RelativeSource={\n RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemType}\n}\n...\n" }, { "answer_id": 3547783, "author": "Juve", "author_id": 8986, "author_profile": "https://Stackoverflow.com/users/8986", "pm_score": 4, "selected": false, "text": "Binding ElementName" }, { "answer_id": 11833632, "author": "Luis Perez", "author_id": 984780, "author_profile": "https://Stackoverflow.com/users/984780", "pm_score": 4, "selected": false, "text": "{Binding Path=PathToProperty, RelativeSource={RelativeSource Self}}\n{Binding Path=PathToProperty, RelativeSource={RelativeSource AncestorType={x:Type typeOfAncestor}}}\n{Binding Path=PathToProperty, RelativeSource={RelativeSource TemplatedParent}}\n{Binding Path=Text, ElementName=MyTextBox}\n" }, { "answer_id": 13137935, "author": "Nathan Cooper", "author_id": 1734730, "author_profile": "https://Stackoverflow.com/users/1734730", "pm_score": 4, "selected": false, "text": "Binding b = new Binding();\nb.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, this.GetType(), 1);\nb.Path = new PropertyPath(\"MyElementThatNeedsBinding\");\nMyLabel.SetBinding(ContentProperty, b);\n" }, { "answer_id": 19470853, "author": "Cornel Marian", "author_id": 736113, "author_profile": "https://Stackoverflow.com/users/736113", "pm_score": 6, "selected": false, "text": "<Rectangle Fill=\"Red\" Name=\"rectangle\" \n Height=\"100\" Stroke=\"Black\" \n Canvas.Top=\"100\" Canvas.Left=\"100\"\n Width=\"{Binding ElementName=rectangle,\n Path=Height}\"/>\n" }, { "answer_id": 29946000, "author": "Edd", "author_id": 2399164, "author_profile": "https://Stackoverflow.com/users/2399164", "pm_score": 3, "selected": false, "text": "<Style.Triggers>\n <DataTrigger Binding=\"{Binding Items.Count, RelativeSource={RelativeSource Self}}\" Value=\"0\">\n <Setter Property=\"Background\">\n <Setter.Value>\n <VisualBrush Stretch=\"None\">\n <VisualBrush.Visual>\n <TextBlock Text=\"We did't find any matching records for your search...\" FontSize=\"16\" FontWeight=\"SemiBold\" Foreground=\"LightCoral\"/>\n </VisualBrush.Visual>\n </VisualBrush>\n </Setter.Value>\n </Setter>\n </DataTrigger>\n</Style.Triggers>\n" }, { "answer_id": 34925445, "author": "Kylo Ren", "author_id": 4576125, "author_profile": "https://Stackoverflow.com/users/4576125", "pm_score": 5, "selected": false, "text": "RelativeSource" }, { "answer_id": 38654107, "author": "Kevin VDF", "author_id": 6653298, "author_profile": "https://Stackoverflow.com/users/6653298", "pm_score": 3, "selected": false, "text": "Mode=FindAncestor" }, { "answer_id": 46053079, "author": "Contango", "author_id": 107409, "author_profile": "https://Stackoverflow.com/users/107409", "pm_score": 3, "selected": false, "text": "<DataGridTextColumn Header=\"Price\" Binding=\"{Binding Price}\" IsReadOnly=\"False\"\n Visibility=\"{Binding ShowPrice,\n Converter={StaticResource visibilityConverter}}\"/>\n" }, { "answer_id": 67119194, "author": "james.lee", "author_id": 9438258, "author_profile": "https://Stackoverflow.com/users/9438258", "pm_score": 4, "selected": false, "text": "PresentationFramework.dll" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4918/" ]
84,285
<p>is it legal for a thread to call this.start() inside its own constructor? and if so what potential issues can this cause? I understand that the object wont have fully initialized until the constructor has run to completion but aside from this are there any other issues? </p>
[ { "answer_id": 84550, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 2, "selected": false, "text": "Thread t = new CustomThread();\nt.start();\nactiveThreads.add(t);\n" }, { "answer_id": 84611, "author": "millenomi", "author_id": 6061, "author_profile": "https://Stackoverflow.com/users/6061", "pm_score": 2, "selected": false, "text": "activeThreads.add( CustomThread.newStartedThread() );\n" }, { "answer_id": 9547273, "author": "OldCurmudgeon", "author_id": 823393, "author_profile": "https://Stackoverflow.com/users/823393", "pm_score": 1, "selected": false, "text": "public class ThreadCreationTest {\n public static void main(String[] args) throws InterruptedException {\n final AtomicInteger threads_created = new AtomicInteger(0);\n while (true) {\n final CountDownLatch latch = new CountDownLatch(1);\n new Thread() {\n { start(); } // <--- Like this ... sweet and simple.\n public void run() {\n latch.countDown();\n synchronized (this) {\n System.out.println(\"threads created: \" +\n threads_created.incrementAndGet());\n try {\n wait();\n } catch (InterruptedException e) {\n Thread.currentThread().interrupt();\n }\n }\n }\n };\n latch.await();\n }\n }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
84,290
<p>How do I get a a complete list of all the urls that my rails application could generate? </p> <p>I don't want the routes that I get get form rake routes, instead I want to get the actul URLs corrosponding to all the dynmically generated pages in my application...</p> <p>Is this even possible?</p> <p>(Background: I'm doing this because I want a complete list of URLs for some load testing I want to do, which has to cover the entire breadth of the application)</p>
[ { "answer_id": 84482, "author": "Jeremiah Peschka", "author_id": 11780, "author_profile": "https://Stackoverflow.com/users/11780", "pm_score": 1, "selected": false, "text": "rake routes" }, { "answer_id": 90868, "author": "kch", "author_id": 13989, "author_profile": "https://Stackoverflow.com/users/13989", "pm_score": 4, "selected": true, "text": "$ wget --spider -r -nv -nd -np http://localhost:3209/ 2>&1 | ack -o '(?<=URL:)\\S+'\nhttp://localhost:3209/\nhttp://localhost:3209/robots.txt\nhttp://localhost:3209/agenda/2008/08\nhttp://localhost:3209/agenda/2008/10\nhttp://localhost:3209/agenda/2008/09/01\nhttp://localhost:3209/agenda/2008/09/02\nhttp://localhost:3209/agenda/2008/09/03\n^C\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7473/" ]
84,310
<p>I'm connecting to an AS/400 stored procedure layer using the IBM iSeries Access for Windows package. This provides a .NET DLL with classes similar to those in the <code>System.Data</code> namespace. As such we use their implementation of the connection class and provide it with a connection string.</p> <p>Does anyone know how I can amend the connection string to indicate the default library it should use?</p>
[ { "answer_id": 84374, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 1, "selected": false, "text": "<add name=\"AS400ConnectionString\" connectionString=\"Data Source=DEVL820;Initial Catalog=Q1A_DATABASE_SRVR;Persist Security Info=False;User ID=BLAH;Password=BLAHBLAH;Provider=IBMDASQL.DataSource.1;**Catalog Library List=&quot;HTSUTST, HTEUSRJ, HTEDTA&quot;**\" providerName=\"System.Data.OleDb\" />\n" }, { "answer_id": 84854, "author": "CrashCodes", "author_id": 16260, "author_profile": "https://Stackoverflow.com/users/16260", "pm_score": 2, "selected": false, "text": "DBQ" }, { "answer_id": 97858, "author": "Gustavo Rubio", "author_id": 14533, "author_profile": "https://Stackoverflow.com/users/14533", "pm_score": 2, "selected": false, "text": "Provider=IBMDA400;Data Source=as400.com;User Id=user;Password=password;Default Collection=yourLibrary;\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12277/" ]
84,322
<p>It appears that using perldoc perl gives the list of, e.g. perlre, perlvar, etc.</p> <p>Is this the best place to find the list of what's available as an overview or tutorial or reference manual section? Is there another, better list?</p>
[ { "answer_id": 84417, "author": "moritz", "author_id": 14132, "author_profile": "https://Stackoverflow.com/users/14132", "pm_score": 4, "selected": true, "text": "perldoc perltoc\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8763/" ]
84,330
<p><strong>Here is the updated question:</strong></p> <p>the current query is doing something like:<br></p> <pre><code>$sql1 = "TRUNCATE TABLE fubar"; $sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu"; </code></pre> <p>The first time the method containing this is run, it generates an error message on the truncate since the table doesn't exist yet.</p> <p>Is my only option to do the <code>CREATE TABLE</code>, run the <code>TRUNCATE TABLE</code>, and then fill the table? (3 separate queries)</p> <p><strong>original question was:</strong></p> <p> I've been having a hard time trying to figure out if the following is possible in MySql without having to write block sql:</p> <pre><code>CREATE TABLE fubar IF NOT EXISTS ELSE TRUNCATE TABLE fubar </code></pre> <p>If I run truncate separately before the create table, and the table doesn't exist, then I get an error message. I'm trying to eliminate that error message without having to add any more queries.</p> <p>This code will be executed using PHP.</p>
[ { "answer_id": 84396, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 2, "selected": false, "text": "DROP TABLE IF EXISTS fubar;\nCREATE TABLE fubar;\n" }, { "answer_id": 84405, "author": "Mark Janssen", "author_id": 15828, "author_profile": "https://Stackoverflow.com/users/15828", "pm_score": 2, "selected": false, "text": "CREATE TABLE fubar IF NOT EXISTS\nTRUNCATE TABLE fubar\n" }, { "answer_id": 1666567, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "call Edit_table(database-name,table-name,query-string);" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16186/" ]
84,331
<p>Is there a macro or a way to conditionally copy rows from one worksheet to another in Excel 2003?</p> <p>I'm pulling a list of data from SharePoint via a web query into a blank worksheet in Excel, and then I want to copy the rows for a particular month to a particular worksheet (for example, all July data from a SharePoint worksheet to the Jul worksheet, all June data from a SharePoint worksheet to Jun worksheet, etc.).</p> <p><strong>Sample data</strong></p> <pre><code>Date - Project - ID - Engineer 8/2/08 - XYZ - T0908-5555 - JS 9/4/08 - ABC - T0908-6666 - DF 9/5/08 - ZZZ - T0908-7777 - TS </code></pre> <p>It's not a one-off exercise. I'm trying to put together a dashboard that my boss can pull the latest data from SharePoint and see the monthly results, so it needs to be able to do it all the time and organize it cleanly.</p>
[ { "answer_id": 84526, "author": "BKimmel", "author_id": 13776, "author_profile": "https://Stackoverflow.com/users/13776", "pm_score": 0, "selected": false, "text": "rows = ActiveSheet.UsedRange.Rows\nn = 0\n\nwhile n <= rows\n if ActiveSheet.Rows(n).Cells(DateColumnOrdinal).Value > '8/1/08' AND < '8/30/08' then\n ActiveSheet.Rows(n).CopyTo(DestinationSheet)\n endif\n n = n + 1\nwend\n" }, { "answer_id": 84614, "author": "theo", "author_id": 7870, "author_profile": "https://Stackoverflow.com/users/7870", "pm_score": 3, "selected": false, "text": "Public Sub MoveData(MonthNumber As Integer, SheetName As String)\n\nDim sharePoint As Worksheet\nDim Month As Worksheet\nDim spRange As Range\nDim cell As Range\n\nSet sharePoint = Sheets(\"Sharepoint\")\nSet Month = Sheets(SheetName)\nSet spRange = sharePoint.Range(\"A2\")\nSet spRange = sharePoint.Range(\"A2:\" & spRange.End(xlDown).Address)\nFor Each cell In spRange\n If Format(cell.Value, \"MM\") = MonthNumber Then\n copyRowTo sharePoint.Range(cell.Row & \":\" & cell.Row), Month\n End If\nNext cell\n\nEnd Sub\n\nSub copyRowTo(rng As Range, ws As Worksheet)\n Dim newRange As Range\n Set newRange = ws.Range(\"A1\")\n If newRange.Offset(1).Value <> \"\" Then\n Set newRange = newRange.End(xlDown).Offset(1)\n Else\n Set newRange = newRange.Offset(1)\n End If\n rng.Copy\n newRange.PasteSpecial (xlPasteAll)\nEnd Sub\n" }, { "answer_id": 87356, "author": "Jon Fournier", "author_id": 5106, "author_profile": "https://Stackoverflow.com/users/5106", "pm_score": 1, "selected": false, "text": "Public Sub MoveData(MonthNum As Integer, FromSheet As Worksheet, ToSheet As Worksheet)\n Const DateCol = \"A\" 'column where dates are store\n Const DestCol = \"A\" 'destination column where dates are stored. We use this column to find the last populated row in ToSheet\n Const FirstRow = 2 'first row where date data is stored\n 'Copy range of values to Dates array\n Dates = FromSheet.Range(DateCol & CStr(FirstRow) & \":\" & DateCol & CStr(FromSheet.Range(DateCol & CStr(FromSheet.Rows.Count)).End(xlUp).Row)).Value\n Dim i As Integer\n For i = LBound(Dates) To UBound(Dates)\n If IsDate(Dates(i, 1)) Then\n If Month(CDate(Dates(i, 1))) = MonthNum Then\n Dim CurrRow As Long\n 'get the current row number in the worksheet\n CurrRow = FirstRow + i - 1\n Dim DestRow As Long\n 'get the destination row\n DestRow = ToSheet.Range(DestCol & CStr(ToSheet.Rows.Count)).End(xlUp).Row + 1\n 'copy row CurrRow in FromSheet to row DestRow in ToSheet\n FromSheet.Range(CStr(CurrRow) & \":\" & CStr(CurrRow)).Copy ToSheet.Range(DestCol & CStr(DestRow))\n End If\n End If\n Next i\nEnd Sub\n" }, { "answer_id": 94282, "author": "Robert Mearns", "author_id": 5050, "author_profile": "https://Stackoverflow.com/users/5050", "pm_score": 0, "selected": false, "text": " Sub SeperateData()\n\n Dim vMonthText As Variant\n Dim ExcelLastCell As Range\n Dim intMonth As Integer\n\n vMonthText = Array(\"January\", \"February\", \"March\", \"April\", \"May\", _\n \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\")\n\n ThisWorkbook.Worksheets(\"Sharepoint\").Select\n Range(\"A1\").Select\n\n RowCount = ThisWorkbook.Worksheets(\"Sharepoint\").UsedRange.Rows.Count\n'Forces excel to determine the last cell, Usually only done on save\n Set ExcelLastCell = ThisWorkbook.Worksheets(\"Sharepoint\"). _\n Cells.SpecialCells(xlLastCell)\n'Determines the last cell with data in it\n\n\n Selection.EntireColumn.Insert\n Range(\"A1\").FormulaR1C1 = \"Month No.\"\n Range(\"A2\").FormulaR1C1 = \"=MONTH(RC[1])\"\n Range(\"A2\").Select\n Selection.Copy\n Range(\"A3:A\" & ExcelLastCell.Row).Select\n ActiveSheet.Paste\n Application.CutCopyMode = False\n Calculate\n 'Insert a helper column to determine the month number for the date\n\n For intMonth = 1 To 12\n Range(\"A1\").CurrentRegion.Select\n Selection.AutoFilter Field:=1, Criteria1:=\"\" & intMonth\n Selection.Copy\n ThisWorkbook.Worksheets(\"\" & vMonthText(intMonth - 1)).Select\n Range(\"A1\").Select\n ActiveSheet.Paste\n Columns(\"A:A\").Delete Shift:=xlToLeft\n Cells.Select\n Cells.EntireColumn.AutoFit\n Range(\"A1\").Select\n ThisWorkbook.Worksheets(\"Sharepoint\").Select\n Range(\"A1\").Select\n Application.CutCopyMode = False\n Next intMonth\n 'Filter the data to a particular month\n 'Convert the month number to text\n 'Copy the filtered data to the month sheet\n 'Delete the helper column\n 'Repeat for each month\n\n Selection.AutoFilter\n Columns(\"A:A\").Delete Shift:=xlToLeft\n 'Get rid of the auto-filter and delete the helper column\n\n End Sub\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
84,332
<p>My Access 2000 DB causes me problems - sometimes (haven't pinpointed the cause) the "book" form won't close. Clicking its close button does nothing, File -> Close does nothing, even closing Access results in no action. I don't have an OnClose handler for this form. The only workaround I can find involves opening the Vba editor, making a change to the code for that form (even adding a space and then immediately deleting the space), and then going back to close the "book" form, closing it, and saying "no, I don't want to save the changes". Only then will it close. Any help?</p>
[ { "answer_id": 84907, "author": "Chris OC", "author_id": 11041, "author_profile": "https://Stackoverflow.com/users/11041", "pm_score": 0, "selected": false, "text": "If Me.chkbox Then\n" }, { "answer_id": 88914, "author": "David-W-Fenton", "author_id": 9787, "author_profile": "https://Stackoverflow.com/users/9787", "pm_score": 1, "selected": false, "text": "(Me.Checkbox) \n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12874/" ]
84,341
<p>I have a core file generated on a remote system that I don't have direct access to. I also have local copies of the library files from the remote system, and the executable file for the crashing program.</p> <p>I'd like to analyse this core dump in gdb.</p> <p>For example:</p> <pre><code>gdb path/to/executable path/to/corefile </code></pre> <p>My libraries are in the current directory.</p> <p>In the past I've seen debuggers implement this by supplying the option "-p ." or "-p /=."; so my question is:</p> <p>How can I specify that libraries be loaded first from paths relative to my current directory when analysing a corefile in gdb?</p>
[ { "answer_id": 84546, "author": "Drew Frezell", "author_id": 10954, "author_profile": "https://Stackoverflow.com/users/10954", "pm_score": 7, "selected": true, "text": "set solib-absolute-prefix ./usr\nfile path/to/executable\ncore-file path/to/corefile\n" }, { "answer_id": 84722, "author": "Mike Tunnicliffe", "author_id": 13956, "author_profile": "https://Stackoverflow.com/users/13956", "pm_score": 2, "selected": false, "text": "set solib-search-path path\n" }, { "answer_id": 84778, "author": "bltxd", "author_id": 11892, "author_profile": "https://Stackoverflow.com/users/11892", "pm_score": 2, "selected": false, "text": "ldd path/to/executable\n" }, { "answer_id": 3293122, "author": "psihodelia", "author_id": 215571, "author_profile": "https://Stackoverflow.com/users/215571", "pm_score": 0, "selected": false, "text": "file ECECUTABLE_NAME" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13956/" ]
84,346
<p>How do I create an index on a column in MySQL v 5.0 (myisam db engine) based upon the length of its value its a TEXT data type up to 7000 characters, do I have to add another column with the length of the first column?</p>
[ { "answer_id": 84500, "author": "Henning", "author_id": 7034, "author_profile": "https://Stackoverflow.com/users/7034", "pm_score": 3, "selected": true, "text": "ADD INDEX myIndex(LENGTH(text)))" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16191/" ]
84,378
<p>When using <code>divs</code> when is it best to use a <code>class</code> vs <code>id</code>? </p> <p>Is it best to use <code>class</code>, on say font variant or elements within the html? Then use <code>id</code> for the structure/containers? </p> <p>This is something I've always been a little uncertain on, any help would be great.</p>
[ { "answer_id": 84409, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 5, "selected": false, "text": "<div id=\"section\" class=\"section\">Text</div>\n" }, { "answer_id": 84412, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 0, "selected": false, "text": "<div class=\"code-formatting-style-name\" id=\"myfirstDivForCode\">\n</div>\n" }, { "answer_id": 84416, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 7, "selected": true, "text": "id" }, { "answer_id": 84520, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "div.NavArea ul { /* styles go here */ }\n" }, { "answer_id": 84652, "author": "Dave Rutledge", "author_id": 2486915, "author_profile": "https://Stackoverflow.com/users/2486915", "pm_score": 3, "selected": false, "text": "<h2 id=\"CurrentSale\">Product I'm selling</h2>\n" }, { "answer_id": 548337, "author": "Sampson", "author_id": 54680, "author_profile": "https://Stackoverflow.com/users/54680", "pm_score": 5, "selected": false, "text": "<student id=\"JonathanSampson\" class=\"Biology\" />\n<student id=\"MarySmith\" class=\"Biology\" />\n" }, { "answer_id": 13704931, "author": "l2aelba", "author_id": 622813, "author_profile": "https://Stackoverflow.com/users/622813", "pm_score": 0, "selected": false, "text": "<div id=\"post-289\" class=\"box clear black bold radius\">\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16195/" ]
84,404
<p>Visual Studio 2003 and 2005 (and perhaps 2008 for all I know) require the command line user to run in the 'Visual Studio Command Prompt'. When starting this command prompt it sets various environment variables that the C++ compiler, cl, uses when compiling.</p> <p>This is not always desirable. If, for example, I want to run 'cl' from within Ant, I'd like to avoid having to run Ant from within the 'Visual Studio Command Prompt'. Running vcvars32.bat isn't an option as the environment set by vcvars32.bat would be lost by the time cl was run (if running from within Ant).</p> <p>Is there an easy way to run cl without having to run from within the Visual Studio command prompt?</p>
[ { "answer_id": 84431, "author": "ljs", "author_id": 3394, "author_profile": "https://Stackoverflow.com/users/3394", "pm_score": 3, "selected": false, "text": "C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcvarsall.bat\n" }, { "answer_id": 87052, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 5, "selected": false, "text": "@echo off\n:: Load compilation environment\ncall \"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcvarsall.bat\"\n:: Invoke compiler with any options passed to this batch file\n\"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\\cl.exe\" %*\n" }, { "answer_id": 11053719, "author": "Joel Purra", "author_id": 907779, "author_profile": "https://Stackoverflow.com/users/907779", "pm_score": 0, "selected": false, "text": "Compile and execute other steps.cmd" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6839/" ]
84,421
<p>Is there a built in way to convert an integer in Ruby into its hexadecimal equivalent?</p> <p>Something like the opposite of <a href="http://ruby-doc.org/core-2.0.0/String.html#method-i-to_i" rel="noreferrer"><code>String#to_i</code></a>:</p> <pre><code>"0A".to_i(16) #=&gt;10 </code></pre> <p>Like perhaps:</p> <pre><code>"0A".hex #=&gt;10 </code></pre> <p>I know how to roll my own, but it's probably more efficient to use a built in Ruby function.</p>
[ { "answer_id": 84455, "author": "flxkid", "author_id": 13036, "author_profile": "https://Stackoverflow.com/users/13036", "pm_score": 6, "selected": false, "text": "%" }, { "answer_id": 84485, "author": "Jean", "author_id": 7898, "author_profile": "https://Stackoverflow.com/users/7898", "pm_score": 9, "selected": true, "text": "to_s" }, { "answer_id": 5474985, "author": "Ultrasaurus", "author_id": 682349, "author_profile": "https://Stackoverflow.com/users/682349", "pm_score": 4, "selected": false, "text": "sprintf(\"%02x\", 10).upcase\n" }, { "answer_id": 7882918, "author": "Lri", "author_id": 495470, "author_profile": "https://Stackoverflow.com/users/495470", "pm_score": 6, "selected": false, "text": "p 10.to_s(16) #=> \"a\"\np \"%x\" % 10 #=> \"a\"\np \"%02X\" % 10 #=> \"0A\"\np sprintf(\"%02X\", 10) #=> \"0A\"\np \"#%02X%02X%02X\" % [255, 0, 10] #=> \"#FF000A\"\n" }, { "answer_id": 23266744, "author": "tool maker", "author_id": 2895616, "author_profile": "https://Stackoverflow.com/users/2895616", "pm_score": 3, "selected": false, "text": "p \"%x\" % -1 #=> \"..f\"\np -1.to_s(16) #=> \"-1\"\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6106/" ]
84,422
<p>in XSLT processing, is there a performance difference between apply-template and call-template? In my stylesheets there are many instances where I can use either, which is the best choice?</p>
[ { "answer_id": 85514, "author": "JeniT", "author_id": 6739, "author_profile": "https://Stackoverflow.com/users/6739", "pm_score": 6, "selected": false, "text": "<xsl:apply-templates>" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
84,427
<p>Specifically, is the following legal C++?</p> <pre>class A{}; void foo(A*); void bar(const A&); int main(void) { foo(&A()); // 1 bar(A()); // 2 }</pre> <p>It appears to work correctly, but that doesn't mean it's necessarily legal. Is it?</p> <p><i>Edit - changed <code>A&amp;</code> to <code>const A&amp;</code></i></p>
[ { "answer_id": 84494, "author": "roo", "author_id": 716, "author_profile": "https://Stackoverflow.com/users/716", "pm_score": -1, "selected": false, "text": "int dosomething(error_code& _e = ignore_errorcode()) {\n //do something\n}\n" }, { "answer_id": 84521, "author": "Matt Price", "author_id": 852, "author_profile": "https://Stackoverflow.com/users/852", "pm_score": 3, "selected": false, "text": "class A{};\n\nvoid bar(const A&);\n\nint main(void)\n{\n bar(A()); // 2\n}\n" }, { "answer_id": 1152218, "author": "CsTamas", "author_id": 140006, "author_profile": "https://Stackoverflow.com/users/140006", "pm_score": 2, "selected": false, "text": "bar(const A&)" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9530/" ]
84,449
<p>The XML Schema Part 2 specifies that an instance of a datatype that is defined as boolean can have the following legal literals {true, false, 1, 0}. The following XML, for example, when deserialized, sets the boolean property "Emulate" to <code>true</code>.</p> <pre><code>&lt;root&gt; &lt;emulate&gt;1&lt;/emulate&gt; &lt;/root&gt; </code></pre> <p>However, when I serialize the object back to the XML, I get <code>true</code> instead of the numerical value. My question is, is there a way that I can control the boolean representation in the XML?</p>
[ { "answer_id": 85468, "author": "Simon Steele", "author_id": 4591, "author_profile": "https://Stackoverflow.com/users/4591", "pm_score": 6, "selected": false, "text": "[XmlIgnore]\npublic bool MyValue { get; set; }\n\n/// <summary>Get a value purely for serialization purposes</summary>\n[XmlElement(\"MyValue\")]\npublic string MyValueSerialize\n{\n get { return this.MyValue ? \"1\" : \"0\"; }\n set { this.MyValue = XmlConvert.ToBoolean(value); }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8205/" ]
84,460
<p>I've been using Destop.open() to launch a .pdf viewer on Windows machines, both Vista and XP, and most of them work just fine. However, on one XP machine the call does not work, simply returning without throwing any exceptions, and the viewer does not launch. On that machine the file association is properly set up as far as I can tell: double-clicking a .pdf works, as does the "start xxx.pdf" command on the command prompt. I'm thinking it must be a Windows configuration issue, but can't put my finger on it.</p> <p>Has anyone else seen this problem?</p>
[ { "answer_id": 84529, "author": "Martin Spamer", "author_id": 15527, "author_profile": "https://Stackoverflow.com/users/15527", "pm_score": 2, "selected": false, "text": "Control Panel->Java Control Panel->Advanced->Java Console.\n" }, { "answer_id": 9962004, "author": "Lund Wolfe", "author_id": 1247753, "author_profile": "https://Stackoverflow.com/users/1247753", "pm_score": 1, "selected": false, "text": "Runtime rt = Runtime.getRuntime();\nrt.exec(new String[]{\"explorer\", \"C:\\\\myfile.pdf\"});\nrt.exec(new String[]{\"explorer\", \"C:\\\\myfile.wmv\"});\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16213/" ]
84,463
<p>For example I want to be able to programatically hit a line of code like the following where the function name is dynamically assigned without using Evaluate(). The code below of course doesn't work but represents what I would like to do.</p> <pre><code>application.obj[funcName](argumentCollection=params) </code></pre> <p>The only way I can find to call a function dynamically is by using cfinvoke, but as far as I can tell that instantiates the related cfc/function on the fly and can't use a previously instantiated cfc.</p> <p>Thanks</p>
[ { "answer_id": 84836, "author": "Ben Doom", "author_id": 12267, "author_profile": "https://Stackoverflow.com/users/12267", "pm_score": 4, "selected": true, "text": "<!--- Create the component instance. --->\n<cfobject component=\"tellTime2\" name=\"tellTimeObj\">\n<!--- Invoke the methods. --->\n<cfinvoke component=\"#tellTimeObj#\" method=\"getLocalTime\" returnvariable=\"localTime\">\n<cfinvoke component=\"#tellTimeObj#\" method=\"getUTCTime\" returnvariable=\"UTCTime\">\n" }, { "answer_id": 84840, "author": "Patrick McElhaney", "author_id": 437, "author_profile": "https://Stackoverflow.com/users/437", "pm_score": 2, "selected": false, "text": "<cfinvoke method=\"application.#funcName#\" argumentCollection=\"#params#\">\n" }, { "answer_id": 7802182, "author": "Nick Harvey", "author_id": 788583, "author_profile": "https://Stackoverflow.com/users/788583", "pm_score": 1, "selected": false, "text": "<!--- get the component (has methods 'sayHi' and a method 'sayHello') --->\n<cfset myObj = createObject(\"component\", \"test_object\")>\n\n<!--- set the function that we want dynamically then call it (it's a two step process) --->\n<cfset func = \"sayHi\">\n<cfset funcInstance = myObj[func]>\n<cfoutput>#funcInstance(\"Dave\")#</cfoutput>\n\n<cfset func = \"sayHello\">\n<cfset funcInstance = myObj[func]>\n<cfoutput>#funcInstance(\"Dave\")#</cfoutput>\n" }, { "answer_id": 7805955, "author": "Aaron Greenlee", "author_id": 88813, "author_profile": "https://Stackoverflow.com/users/88813", "pm_score": 1, "selected": false, "text": "funcName = 'foobar'; \napplication.obj.$fn = application.obj[funcName];\napplication.obj.$fn(argumentCollection=arguments);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8345/" ]
84,486
<p>I've spent far too much time trying to figure this out. This should be the simplest thing and everyone who distributes Java applications in jars must have to deal with it.</p> <p>I just want to know the proper way to add versioning to my Java app so that I can access the version information when I'm testing, e.g. debugging in Eclipse <strong>and</strong> running from a jar.</p> <p>Here's what I have in my build.xml:</p> <pre><code>&lt;target name="jar" depends = "compile"&gt; &lt;property name="version.num" value="1.0.0"/&gt; &lt;buildnumber file="build.num"/&gt; &lt;tstamp&gt; &lt;format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" /&gt; &lt;/tstamp&gt; &lt;manifest file="${build}/META-INF/MANIFEST.MF"&gt; &lt;attribute name="Built-By" value="${user.name}" /&gt; &lt;attribute name="Built-Date" value="${TODAY}" /&gt; &lt;attribute name="Implementation-Title" value="MyApp" /&gt; &lt;attribute name="Implementation-Vendor" value="MyCompany" /&gt; &lt;attribute name="Implementation-Version" value="${version.num}-b${build.number}"/&gt; &lt;/manifest&gt; &lt;jar destfile="${build}/myapp.jar" basedir="${build}" excludes="*.jar" /&gt; &lt;/target&gt; </code></pre> <p>This creates /META-INF/MANIFEST.MF and I can read the values when I'm debugging in Eclipse thusly:</p> <pre><code>public MyClass() { try { InputStream stream = getClass().getResourceAsStream("/META-INF/MANIFEST.MF"); Manifest manifest = new Manifest(stream); Attributes attributes = manifest.getMainAttributes(); String implementationTitle = attributes.getValue("Implementation-Title"); String implementationVersion = attributes.getValue("Implementation-Version"); String builtDate = attributes.getValue("Built-Date"); String builtBy = attributes.getValue("Built-By"); } catch (IOException e) { logger.error("Couldn't read manifest."); } </code></pre> <p>}</p> <p>But, when I create the jar file, it loads the manifest of another jar (presumably the first jar loaded by the application - in my case, activation.jar).</p> <p>Also, the following code doesn't work either although all the proper values are in the manifest file.</p> <pre><code> Package thisPackage = getClass().getPackage(); String implementationVersion = thisPackage.getImplementationVersion(); </code></pre> <p>Any ideas?</p>
[ { "answer_id": 84945, "author": "Martin Spamer", "author_id": 15527, "author_profile": "https://Stackoverflow.com/users/15527", "pm_score": 1, "selected": false, "text": "this.getClass().getClassLoader().getResourceAsStream( ... ) ;\n" }, { "answer_id": 94325, "author": "basszero", "author_id": 287, "author_profile": "https://Stackoverflow.com/users/287", "pm_score": 2, "selected": false, "text": "Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(\"META-INF/MANIFEST.MF\");\n" }, { "answer_id": 149477, "author": "user16216", "author_id": 16216, "author_profile": "https://Stackoverflow.com/users/16216", "pm_score": 1, "selected": false, "text": "package com.company.division.project.packageversion;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.jar.Attributes;\nimport java.util.jar.Manifest;\n\npublic class packageVersion\n{\n void printVersion()\n {\n try\n { \n InputStream stream = getClass().getResourceAsStream(\"/META-INF/MANIFEST.MF\");\n\n if (stream == null)\n {\n System.out.println(\"Couldn't find manifest.\");\n System.exit(0);\n }\n\n Manifest manifest = new Manifest(stream);\n\n Attributes attributes = manifest.getMainAttributes();\n\n String impTitle = attributes.getValue(\"Implementation-Title\");\n String impVersion = attributes.getValue(\"Implementation-Version\");\n String impBuildDate = attributes.getValue(\"Built-Date\");\n String impBuiltBy = attributes.getValue(\"Built-By\");\n\n if (impTitle != null)\n {\n System.out.println(\"Implementation-Title: \" + impTitle);\n } \n if (impVersion != null)\n {\n System.out.println(\"Implementation-Version: \" + impVersion);\n }\n if (impBuildDate != null)\n {\n System.out.println(\"Built-Date: \" + impBuildDate);\n }\n if (impBuiltBy != null)\n {\n System.out.println(\"Built-By: \" + impBuiltBy);\n }\n\n System.exit(0);\n }\n catch (IOException e)\n { \n System.out.println(\"Couldn't read manifest.\");\n } \n }\n\n /**\n * @param args\n */\n public static void main(String[] args)\n {\n packageVersion version = new packageVersion();\n version.printVersion(); \n }\n\n}\n" }, { "answer_id": 3069207, "author": "Glenn Burkhardt", "author_id": 370243, "author_profile": "https://Stackoverflow.com/users/370243", "pm_score": 1, "selected": false, "text": "String cp = PCAS.class.getResource(PCAS.class.getSimpleName() + \".class\").toString();\ncp = cp.substring(0, cp.indexOf(PCAS.class.getPackage().getName())) \n + \"META-INF/MANIFEST.MF\";\nManifest mf = new Manifest((new URL(cp)).openStream());\n" }, { "answer_id": 3071608, "author": "gibbss", "author_id": 116621, "author_profile": "https://Stackoverflow.com/users/116621", "pm_score": 4, "selected": false, "text": "@Test\npublic void testManifest() throws IOException {\n URL res = org.junit.Assert.class.getResource(org.junit.Assert.class.getSimpleName() + \".class\");\n JarURLConnection conn = (JarURLConnection) res.openConnection();\n Manifest mf = conn.getManifest();\n Attributes atts = mf.getMainAttributes();\n for (Object v : atts.values()) {\n System.out.println(v);\n }\n}\n" }, { "answer_id": 14089550, "author": "yegor256", "author_id": 187141, "author_profile": "https://Stackoverflow.com/users/187141", "pm_score": 0, "selected": false, "text": "Manifests" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16216/" ]
84,488
<p>Is there some built-in way to share files between Xen guests? I don't currently need to share the actual images, just some data files.</p>
[ { "answer_id": 35119359, "author": "Vorell", "author_id": 5865147, "author_profile": "https://Stackoverflow.com/users/5865147", "pm_score": 1, "selected": false, "text": "xvda3" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9594/" ]
84,506
<p>I find from reading perldoc perlvar, about a thousand lines in is help for %ENV. Is there a way to find that from the command line directly?</p> <p>On my Windows machine, I've tried the following</p> <pre><code>perldoc ENV perldoc %ENV perldoc %%ENV perldoc -r ENV (returns info about Use Env) perldoc -r %ENV perldoc -r %%%ENV perldoc -r %%%%ENV (says No documentation found for "%ENV") </code></pre> <p>None actually return information about the %ENV variable.</p> <p>How do I use perldoc to find out about %ENV, if I don't want to have to eye-grep through thousands of line?</p> <p>I've tried the suggested "perldoc perlvar" and then typing /%ENV, but nothing happens. </p> <pre><code>perl -v: This is perl, v5.8.0 built for MSWin32-x86-multi-thread </code></pre> <p>Though I've asked about %ENV, this also applies to any general term, so knowing that %ENV is in perlvar for this one example won't help me next time when I don't know which section.</p> <p>Is there a way to get perldoc to dump everything (ugh) and I can grep the output?</p>
[ { "answer_id": 84786, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 0, "selected": false, "text": "unixutils" }, { "answer_id": 84791, "author": "Ovid", "author_id": 8003, "author_profile": "https://Stackoverflow.com/users/8003", "pm_score": 4, "selected": false, "text": "$ perldoc -v '%ENV'\n\n%ENV\n$ENV{expr}\nThe hash %ENV contains your current environment. Setting a value in\n\"ENV\" changes the environment for any child processes you subsequently\nfork() off.\n" }, { "answer_id": 91195, "author": "ysth", "author_id": 17389, "author_profile": "https://Stackoverflow.com/users/17389", "pm_score": 0, "selected": false, "text": "firefox http://perldoc.perl.org/perlvar.html#%ENV\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8763/" ]
84,556
<p>Personally I like this one:</p> <p><img src="https://i.stack.imgur.com/ZNtvc.jpg" alt=""></p> <p>P.S. Do not hotlink the cartoon without the site's permission please. </p>
[ { "answer_id": 1469915, "author": "fixxxer", "author_id": 170005, "author_profile": "https://Stackoverflow.com/users/170005", "pm_score": 3, "selected": false, "text": "HAI\nCAN HAS STDIO?\nI HAS A VAR\nIM IN YR LOOP\n UP VAR!!1\n VISIBLE VAR\n IZ VAR BIGGER THAN 10? KTHXBYE\nIM OUTTA YR LOOP\nKTHXBAI\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4230/" ]
84,583
<p>The DBAs here maintain all SQL Server and SQL Reporting servers. I have a custom developed SQL Reporting 2005 project in Visual Studio that runs fine on my local SQL Database and Reporting instances. I need to deploy to a production server, so I had a folder created on a SQL Reporting 2005 server with permissions to upload files. Normally, a deploy from within Visual Studio is all that is needed to upload the report files.</p> <p>However, for security purposes, data sources are maintained explicitly by DBAs and stored in a separated locked down common folder on the reporting server. I had them create the data source for me.</p> <p>When I attempt to deploy from VS, it gives me the error </p> <blockquote> <p>The item '/Data Sources' already exists.</p> </blockquote> <p>I get this whether I'm deploying the whole project or just a single report file. I already set <code>OverwriteDataSources=false</code> in the project properties. The TargetServer URL and folder are verified correct.</p> <p>I suppose I could copy the files manually, but I'd like to be able to deploy from within VS. What could I be doing wrong?</p>
[ { "answer_id": 156077, "author": "Peter Wone", "author_id": 1715673, "author_profile": "https://Stackoverflow.com/users/1715673", "pm_score": 2, "selected": false, "text": " <DataSources>\n <DataSource Name=\"preserve the datasource name you've been using\">\n <ConnectionProperties>\n <DataProvider>SQL</DataProvider>\n <ConnectString>=Parameters!ConnectionString.Value</ConnectString>\n </ConnectionProperties>\n <rd:DataSourceID>preserve your existing GUID</rd:DataSourceID>\n </DataSource>\n </DataSources>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3347/" ]
84,644
<p>To make it short: hibernate doesn't support projections and query by example? I found this post:</p> <p>The code is this:</p> <pre><code>User usr = new User(); usr.setCity = 'TEST'; getCurrentSession().createCriteria(User.class) .setProjection( Projections.distinct( Projections.projectionList() .add( Projections.property("name"), "name") .add( Projections.property("city"), "city"))) .add( Example.create(usr)) </code></pre> <p>Like the other poster said, The generated sql keeps having a where class refering to just <strong>y0_= ? instead of this_.city</strong>. </p> <p>I already tried several approaches, and searched the issue tracker but found nothing about this.</p> <p>I even tried to use Projection alias and Transformers, but it does not work:</p> <pre><code>User usr = new User(); usr.setCity = 'TEST'; getCurrentSession().createCriteria(User.class) .setProjection( Projections.distinct( Projections.projectionList() .add( Projections.property("name"), "name") .add( Projections.property("city"), "city"))) .add( Example.create(usr)).setResultTransformer(Transformers.aliasToBean(User.class)); </code></pre> <p>Has anyone used projections and query by example ?</p>
[ { "answer_id": 86752, "author": "Arthur Thomas", "author_id": 14009, "author_profile": "https://Stackoverflow.com/users/14009", "pm_score": 5, "selected": true, "text": "getCurrentSession().createCriteria(User.class)\n.setProjection( Projections.distinct( Projections.projectionList()\n.add( Projections.property(\"name\"), \"name\")\n.add( Projections.property(\"city\"), \"city\")))\n.add( Restrictions.eq(\"city\", \"TEST\")))\n.setResultTransformer(Transformers.aliasToBean(User.class))\n.list();\n" }, { "answer_id": 960278, "author": "Ryan Cook", "author_id": 43029, "author_profile": "https://Stackoverflow.com/users/43029", "pm_score": 6, "selected": false, "text": "Criteria criteria = session.createCriteria(MyClass.class)\n .setProjection(Projections.projectionList()\n .add(Projections.property(\"sectionHeader\"), \"sectionHeader\")\n .add(Projections.property(\"subSectionHeader\"), \"subSectionHeader\")\n .add(Projections.property(\"sectionNumber\"), \"sectionNumber\"))\n .add(Restrictions.ilike(\"sectionHeader\", sectionHeaderVar)) // <- Problem!\n .setResultTransformer(Transformers.aliasToBean(MyDTO.class));\n" }, { "answer_id": 976595, "author": "VHristov", "author_id": 120582, "author_profile": "https://Stackoverflow.com/users/120582", "pm_score": 0, "selected": false, "text": "select pageNo, abs(pageNo - 434) as diff\nfrom relA\nwhere year = 2009\norder by diff\n" }, { "answer_id": 35381484, "author": "singh", "author_id": 5922685, "author_profile": "https://Stackoverflow.com/users/5922685", "pm_score": 0, "selected": false, "text": "ProjectionList pl = Projections.projectionList();\npl.add(Projections.property(\"id\"));\npl.add(Projections.sqlProjection(\"abs(`pageNo`-\" + pageNo + \") as diff\", new String[] {\"diff\"}, types ), diff); ---- solution\ncrit.addOrder(Order.asc(\"diff\"));\ncrit.setProjection(pl);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
84,661
<p>Sometimes, in PL SQL you want to add a parameter to a Package, Function or Procedure in order to prepare future functionality. For example:</p> <pre><code>create or replace function doGetMyAccountMoney( Type_Of_Currency IN char := 'EUR') return number is Result number(12,2); begin Result := 10000; IF char &lt;&gt; 'EUR' THEN -- ERROR NOT IMPLEMENTED YET END IF; return(Result); end doGetMyAccountMoney;also </code></pre> <p>It can lead to lots of warnings like</p> <pre><code>Compilation errors for FUNCTION APPUEMP_PRAC.DOGETMYACCOUNTMONEY Error: Hint: Parameter 'Currency' is declared but never used in 'doGetMyAccountMoney' Line: 1 </code></pre> <p>What would be the best way to avoid those warnings? </p>
[ { "answer_id": 88742, "author": "Sergey Stadnik", "author_id": 10557, "author_profile": "https://Stackoverflow.com/users/10557", "pm_score": 1, "selected": false, "text": "ALTER SESSION SET PLSQL_WARNINGS='ENABLE:SEVERE';\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16206/" ]
84,680
<p>I'm writing a Spring web application that requires users to login. My company has an Active Directory server that I'd like to make use of for this purpose. However, I'm having trouble using Spring Security to connect to the server.</p> <p>I'm using Spring 2.5.5 and Spring Security 2.0.3, along with Java 1.6.</p> <p>If I change the LDAP URL to the wrong IP address, it doesn't throw an exception or anything, so I'm wondering if it's even <em>trying</em> to connect to the server to begin with.</p> <p>Although the web application starts up just fine, any information I enter into the login page is rejected. I had previously used an InMemoryDaoImpl, which worked fine, so the rest of my application seems to be configured correctly.</p> <p>Here are my security-related beans:</p> <pre><code> &lt;beans:bean id="ldapAuthProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider"&gt; &lt;beans:constructor-arg&gt; &lt;beans:bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator"&gt; &lt;beans:constructor-arg ref="initialDirContextFactory" /&gt; &lt;beans:property name="userDnPatterns"&gt; &lt;beans:list&gt; &lt;beans:value&gt;CN={0},OU=SBSUsers,OU=Users,OU=MyBusiness,DC=Acme,DC=com&lt;/beans:value&gt; &lt;/beans:list&gt; &lt;/beans:property&gt; &lt;/beans:bean&gt; &lt;/beans:constructor-arg&gt; &lt;/beans:bean&gt; &lt;beans:bean id="userDetailsService" class="org.springframework.security.userdetails.ldap.LdapUserDetailsManager"&gt; &lt;beans:constructor-arg ref="initialDirContextFactory" /&gt; &lt;/beans:bean&gt; &lt;beans:bean id="initialDirContextFactory" class="org.springframework.security.ldap.DefaultInitialDirContextFactory"&gt; &lt;beans:constructor-arg value="ldap://192.168.123.456:389/DC=Acme,DC=com" /&gt; &lt;/beans:bean&gt; </code></pre>
[ { "answer_id": 86367, "author": "delfuego", "author_id": 16414, "author_profile": "https://Stackoverflow.com/users/16414", "pm_score": 6, "selected": true, "text": "<beans:bean id=\"contextSource\"\n class=\"org.springframework.security.ldap.DefaultSpringSecurityContextSource\">\n <beans:constructor-arg value=\"ldap://hostname.queso.com:389/\" />\n</beans:bean>\n\n<beans:bean id=\"ldapAuthenticationProvider\"\n class=\"org.queso.ad.service.authentication.LdapAuthenticationProvider\">\n <beans:property name=\"authenticator\" ref=\"ldapAuthenticator\" />\n <custom-authentication-provider />\n</beans:bean>\n\n<beans:bean id=\"ldapAuthenticator\"\n class=\"org.queso.ad.service.authentication.LdapAuthenticatorImpl\">\n <beans:property name=\"contextFactory\" ref=\"contextSource\" />\n <beans:property name=\"principalPrefix\" value=\"QUESO\\\" />\n</beans:bean>\n" }, { "answer_id": 12468450, "author": "rjc730", "author_id": 714366, "author_profile": "https://Stackoverflow.com/users/714366", "pm_score": 0, "selected": false, "text": "$ host -t SRV _ldap._tcp.samdom.example.com.\n_ldap._tcp.samdom.example.com has SRV record 0 100 389 samba.samdom.example.com.\n" }, { "answer_id": 26425976, "author": "Cookalino", "author_id": 1069027, "author_profile": "https://Stackoverflow.com/users/1069027", "pm_score": 1, "selected": false, "text": "ldapAuthProvider1(ActiveDirectoryLdapAuthenticationProvider,\n \"mydomain.com\",\n \"ldap://mydomain.com/\"\n)\n" }, { "answer_id": 36738996, "author": "Riddhi Gohil", "author_id": 5947458, "author_profile": "https://Stackoverflow.com/users/5947458", "pm_score": 1, "selected": false, "text": "@Configuration\n@EnableWebSecurity\npublic class SecurityConfig extends WebSecurityConfigurerAdapter {\n\n\nstatic final Logger LOGGER = LoggerFactory.getLogger(SecurityConfig.class);\n\n@Autowired\nprotected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {\n auth.authenticationProvider(activeDirectoryLdapAuthenticationProvider());\n}\n\n@Override\nprotected void configure(HttpSecurity http) throws Exception {\n http\n .authorizeRequests()\n .antMatchers(\"/\").permitAll()\n .anyRequest().authenticated();\n .and()\n .formLogin()\n .and()\n .logout();\n}\n\n@Bean\npublic AuthenticationProvider activeDirectoryLdapAuthenticationProvider() {\n ActiveDirectoryLdapAuthenticationProvider authenticationProvider = \n new ActiveDirectoryLdapAuthenticationProvider(\"<domain>\", \"<url>\");\n\n authenticationProvider.setConvertSubErrorCodesToExceptions(true);\n authenticationProvider.setUseAuthenticationRequestCredentials(true);\n\n return authenticationProvider;\n}\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13379/" ]
84,716
<p>I use the jQuery <a href="http://docs.jquery.com/Utilities/jQuery.extend" rel="nofollow noreferrer">extend</a> function to extend a class prototype.</p> <p>For example:</p> <pre><code>MyWidget = function(name_var) { this.init(name_var); } $.extend(MyWidget.prototype, { // object variables widget_name: '', init: function(widget_name) { // do initialization here this.widget_name = widget_name; }, doSomething: function() { // an example object method alert('my name is '+this.widget_name); } }); // example of using the class built above var widget1 = new MyWidget('widget one'); widget1.doSomething(); </code></pre> <p>Is there a better way to do this? Is there a cleaner way to create the class above with only one statement instead of two?</p>
[ { "answer_id": 84824, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 6, "selected": false, "text": "var MyWidget = Class.extend({\n init: function(widget_name){\n this.widget_name = widget_name;\n },\n\n doSomething: function() {\n alert('my name is ' + this.widget_name);\n }\n});\n" }, { "answer_id": 88452, "author": "Devon", "author_id": 13850, "author_profile": "https://Stackoverflow.com/users/13850", "pm_score": 4, "selected": false, "text": "// Inspired by base2 and Prototype\n(function(){\n var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\\b_super\\b/ : /.*/;\n\n // The base Class implementation (does nothing)\n this.Class = function(){};\n\n // Create a new Class that inherits from this class\n Class.extend = function(prop) {\n var _super = this.prototype;\n\n // Instantiate a base class (but only create the instance,\n // don't run the init constructor)\n initializing = true;\n var prototype = new this();\n initializing = false;\n\n // Copy the properties over onto the new prototype\n for (var name in prop) {\n // Check if we're overwriting an existing function\n prototype[name] = typeof prop[name] == \"function\" &&\n typeof _super[name] == \"function\" && fnTest.test(prop[name]) ?\n (function(name, fn){\n return function() {\n var tmp = this._super;\n\n // Add a new ._super() method that is the same method\n // but on the super-class\n this._super = _super[name];\n\n // The method only need to be bound temporarily, so we\n // remove it when we're done executing\n var ret = fn.apply(this, arguments); \n this._super = tmp;\n\n return ret;\n };\n })(name, prop[name]) :\n prop[name];\n }\n\n // The dummy class constructor\n function Class() {\n // All construction is actually done in the init method\n if ( !initializing && this.init )\n this.init.apply(this, arguments);\n }\n\n // Populate our constructed prototype object\n Class.prototype = prototype;\n\n // Enforce the constructor to be what we expect\n Class.constructor = Class;\n\n // And make this class extendable\n Class.extend = arguments.callee;\n\n return Class;\n };\n})();\n" }, { "answer_id": 14007970, "author": "Paul Allsopp", "author_id": 1620987, "author_profile": "https://Stackoverflow.com/users/1620987", "pm_score": 5, "selected": false, "text": "var myClass = function(){};\nmyClass.prototype = {\n some_property: null,\n some_other_property: 0,\n\n doSomething: function(msg) {\n this.some_property = msg;\n alert(this.some_property);\n }\n};\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13850/" ]
84,717
<p>What are the best conventions of naming testing-assemblies in .NET (or any other language or platform)?</p> <p>What I'm mainly split between are these options (please provide others!):</p> <ul> <li><strong>Company.Website</strong> - <em>the project</em></li> <li><strong>Company.Website.Tests</strong></li> </ul> <p><em>or</em></p> <ul> <li><strong>Company.Website</strong></li> <li><strong>Company.WebsiteTests</strong></li> </ul> <p>The problem with the first solution is that it looks like .Tests are a sub-namespace to the site, while they really are more parallel in my mind. What happens when a new sub-namespace comes into play, like <strong>Company.Website.Controls</strong>, where should I put the tests for that namespace, for instance?</p> <p>Maybe it should even be: <strong>Tests.Company.Website</strong> and <strong>Tests.Company.Website.Controls</strong>, and so on.</p>
[ { "answer_id": 84809, "author": "Tom Carr", "author_id": 14954, "author_profile": "https://Stackoverflow.com/users/14954", "pm_score": 1, "selected": false, "text": "Company.Namespace.Test\nCompany.Namespace.Data.Test\n" }, { "answer_id": 84972, "author": "Claus Thomsen", "author_id": 15555, "author_profile": "https://Stackoverflow.com/users/15555", "pm_score": 6, "selected": true, "text": "* Company.Website - the project\n* Company.Website.Tests\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2429/" ]
84,759
<p>This is an Eclipse question, and you can assume the Java package for all these Eclipse classes is <code>org.eclipse.core.resources</code>. </p> <p>I want to get an <code>IFile</code> corresponding to a location <code>String</code> I have:</p> <pre><code> "platform:/resource/Tracbility_All_Supported_lib/processes/gastuff/globalht/GlobalHTInterface.wsdl" </code></pre> <p>I have the enclosing <code>IWorkspace</code> and <code>IWorkspaceRoot</code>. If I had the <code>IPath</code> corresponding to the location above, I could simply call <code>IWorkspaceRoot.getFileForLocation(IPath)</code>.</p> <p>How do I get the corresponding <code>IPath</code> from the location <code>String</code>? Or is there some other way to get the corresponding <code>IFile</code>?</p>
[ { "answer_id": 85074, "author": "Paul Reiners", "author_id": 7648, "author_profile": "https://Stackoverflow.com/users/7648", "pm_score": 2, "selected": false, "text": "String platformLocationString = portTypeContainer\n .getLocation();\nString locationString = platformLocationString\n .substring(\"platform:/resource/\".length());\nIWorkspace workspace = ResourcesPlugin.getWorkspace();\nIWorkspaceRoot workspaceRoot = workspace.getRoot();\nIFile wSDLFile = (IFile) workspaceRoot\n .findMember(locationString);\n" }, { "answer_id": 85128, "author": "Tirno", "author_id": 9886, "author_profile": "https://Stackoverflow.com/users/9886", "pm_score": 3, "selected": true, "text": "IPath p = new Path(locationString);\nIWorkspaceRoot.getFileForLocation(p);\n" }, { "answer_id": 85502, "author": "Roel Spilker", "author_id": 12634, "author_profile": "https://Stackoverflow.com/users/12634", "pm_score": 2, "selected": false, "text": "workspaceRoot.findMember(String name)" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7648/" ]
84,782
<p>I am writting JAVA programme using JDBC for database conntectivity , I am calling one stored procedure in that which is returning ORACLE REF CURSOR , IS there any way I can handle that without importing ORACLE PACKAGES ?</p>
[ { "answer_id": 85766, "author": "jwiklund", "author_id": 4208, "author_profile": "https://Stackoverflow.com/users/4208", "pm_score": 2, "selected": true, "text": "select * from table( sp_returning( ? ) )\n" }, { "answer_id": 411052, "author": "tuinstoel", "author_id": 43901, "author_profile": "https://Stackoverflow.com/users/43901", "pm_score": -1, "selected": false, "text": "select * from table( sp_returning( ? ) )\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14299/" ]
84,795
<p>How can I optimize the following code, which currently takes over 2 minutes to retrieve and loop through 800+ records from a pool of over 100K records, returning 6 fields per record (adds approximately 20 seconds per additional field):</p> <pre><code>&lt;cfset dllPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.DirectoryServices.dll" /&gt; &lt;cfset LDAPPath="LDAP://" &amp; arguments.searchPath /&gt; &lt;cfset theLookUp=CreateObject(".NET","System.DirectoryServices.DirectoryEntry", dllPath).init(LDAPPath) /&gt; &lt;cfset theSearch=CreateObject(".NET","System.DirectoryServices.DirectorySearcher", dllPath).init(theLookUp) /&gt; &lt;cfset theSearch.Set_Filter(arguments.theFilter) /&gt; &lt;cfset theObject = theSearch.FindAll() /&gt; &lt;cfloop index="row" from="#startRow#" to="#endRow#"&gt; &lt;cfset QueryAddRow(theQuery) /&gt; &lt;cfloop list="#columnList#" index="col"&gt; &lt;cfloop from="0" to="#theObject.Get_Item(row).Get_Properties().Get_Item(col).Get_Count()-1#" index="item"&gt; &lt;cftry&gt; &lt;cfset theQuery[col][theQuery.recordCount]=ListAppend(theQuery[col][theQuery.recordCount],theObject.Get_Item(row).Get_Properties().Get_Item(col).Get_Item(item),"|") /&gt; &lt;cfcatch type="any"&gt; &lt;/cfcatch&gt; &lt;/cftry&gt; &lt;/cfloop&gt; &lt;/cfloop&gt; &lt;/cfloop&gt; </code></pre>
[ { "answer_id": 85913, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 3, "selected": true, "text": "<cfset dllPath=\"C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322\\System.DirectoryServices.dll\" />\n<cfset LDAPPath=\"LDAP://\" & arguments.searchPath />\n<cfset theLookUp=CreateObject(\".NET\",\"System.DirectoryServices.DirectoryEntry\", dllPath).init(LDAPPath) />\n<cfset theSearch=CreateObject(\".NET\",\"System.DirectoryServices.DirectorySearcher\", dllPath).init(theLookUp) />\n<cfset theSearch.Set_Filter(arguments.theFilter) />\n<cfset theObject = theSearch.FindAll() />\n\n<cfloop index=\"row\" from=\"#startRow#\" to=\"#endRow#\">\n\n <cfset Props = theObject.get_item(row).get_properties() />\n\n <cfset QueryAddRow(theQuery) />\n\n <cfloop list=\"#columnList#\" index=\"col\">\n\n <cfset CurrentCol = Props.getItem(col) />\n\n <cfset ItemArray = ArrayNew(1)/>\n <cfloop from=\"0\" to=\"#CurrentCol.getcount() - 1#\" index=\"item\">\n <cftry>\n <cfset ArrayAppend( ItemArray , CurrentCol.Get_Item(item) )/>\n <cfcatch type=\"any\">\n </cfcatch>\n </cftry>\n </cfloop>\n <cfset theQuery[col][theQuery.recordCount] = ArrayToList( ItemArray , '|' )/>\n\n </cfloop>\n\n</cfloop>\n" }, { "answer_id": 85944, "author": "kooshmoose", "author_id": 7436, "author_profile": "https://Stackoverflow.com/users/7436", "pm_score": 0, "selected": false, "text": "<cfloop index=\"row\" from=\"#startRow#\" to=\"#endRow#\">\n<cfset QueryAddRow(theQuery) />\n<cfloop list=\"#columnList#\" index=\"col\">\n <cfset PipedVals = \"\">\n <cfset theItem = theObject.Get_Item(row).Get_Properties().Get_Item(col)>\n <cfset ColCount = theItem.Get_Count()-1>\n <cfloop from=\"0\" to=\"#ColCount#\" index=\"item\">\n <cftry>\n <cfset PipedVals = ListAppend(PipedVals,theItem.Get_Item(item),\"|\")>\n <cfcatch type=\"any\"></cfcatch>\n </cftry>\n </cfloop>\n <cfset QuerySetCell(theQuery,col) = PipedVals>\n</cfloop>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16289/" ]
84,800
<p>I am looking for an efficient way to pull the data I want out of an array called $submission_info so I can easily auto-fill my form fields. The array size is about 120.</p> <p>I want to find the field name and extract the content. In this case, the field name is <strong>loanOfficer</strong> and the content is <strong>John Doe</strong>.</p> <pre><code>Output of Print_r($submission_info[1]): Array ( [field_id] =&gt; 2399 [form_id] =&gt; 4 [field_name] =&gt; loanOfficer [field_test_value] =&gt; ABCDEFGHIJKLMNOPQRSTUVWXYZ [field_size] =&gt; medium [field_type] =&gt; other [data_type] =&gt; string [field_title] =&gt; LoanOfficer [col_name] =&gt; loanOfficer [list_order] =&gt; 2 [admin_display] =&gt; yes [is_sortable] =&gt; yes [include_on_redirect] =&gt; yes [option_orientation] =&gt; vertical [file_upload_dir] =&gt; [file_upload_url] =&gt; [file_upload_max_size] =&gt; 1000000 [file_upload_types] =&gt; [content] =&gt; John Doe ) </code></pre> <p>I want to find the field name and extract the content. In this case, the field name is <strong>loanOfficer</strong> and the content is <strong>John Doe</strong>.</p>
[ { "answer_id": 85117, "author": "Randy", "author_id": 9361, "author_profile": "https://Stackoverflow.com/users/9361", "pm_score": 3, "selected": true, "text": "foreach($submission_info as $elem) {\n $newarray[$elem[\"field_name\"]] = $elem[\"content\"];\n}\n" }, { "answer_id": 85199, "author": "Matthew Encinas", "author_id": 14433, "author_profile": "https://Stackoverflow.com/users/14433", "pm_score": 1, "selected": false, "text": "foreach($submission_info as $info){\n if($info['field_name'] == 'loanOfficer'){ //check the field name\n $content = $info['content']; //store the desired value\n continue; //this will stop the loop after the desired item is found\n }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16292/" ]
84,803
<p>has anyone else seen this error message. a quick check with google doesn't show me much.</p>
[ { "answer_id": 84900, "author": "jessegavin", "author_id": 5651, "author_profile": "https://Stackoverflow.com/users/5651", "pm_score": 2, "selected": false, "text": "alert($(\"#myElement\").tagName);\n" }, { "answer_id": 5640718, "author": "Abc", "author_id": 369724, "author_profile": "https://Stackoverflow.com/users/369724", "pm_score": 1, "selected": false, "text": "$('body').append('hi!')" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13800/" ]
84,817
<p>We are producing a portable code (win+macOs) and we are looking at how to make the code more rubust as it crashes every so often... (overflows or bad initializations usually) :-(</p> <p>I was reading that Google Chrome uses a process for every tab so if something goes wrong then the program does not crash compleatelly, only that tab. I think that is quite neat, so i might give it a go!</p> <p>So i was wondering if someone has some tips, help, reading list, comment, or something that can help me build more rubust c++ code (portable is always better).</p> <p>In the same topic i was also wondering if there is a portable library for processes (like boost)?</p> <p>Well many Thanks. </p>
[ { "answer_id": 85289, "author": "paercebal", "author_id": 14089, "author_profile": "https://Stackoverflow.com/users/14089", "pm_score": 1, "selected": false, "text": "doSomethingBad(T * t)\n{\n if(t == NULL) return ;\n\n // do the processing.\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16269/" ]
84,837
<p>I have an ASP.NET 1.1 application, and on my local machine the submit button on my page works fine, but when I deploy it to our development application server, I click on Submit and nothing happens.. I'm assuming that the Page_Validate() function is failing and disabling the POSTBACK, but how do I debug this and determine what is failing? It sounds like some config problem since it works great on my local machine but not on the remote server...</p>
[ { "answer_id": 145061, "author": "Mauricio Scheffer", "author_id": 21239, "author_profile": "https://Stackoverflow.com/users/21239", "pm_score": 0, "selected": false, "text": "aspnet_regiis.exe -c" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7243/" ]
84,839
<p>I am trying to create an XML file based on data fields from a table, and I want to have the nodes named based on the value in a field from the table. The problem is that sometimes values entered in that column contain spaces and other characters not allowed in Node names.</p> <p>Does anyone have any code that will cleanup a passed in string and repalce invalid characters with replacement text so that it can be reversed on the other end and get the original value back?</p> <p>I am using .net (vb.net but I can read/convert c#)</p>
[ { "answer_id": 145061, "author": "Mauricio Scheffer", "author_id": 21239, "author_profile": "https://Stackoverflow.com/users/21239", "pm_score": 0, "selected": false, "text": "aspnet_regiis.exe -c" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1889/" ]
84,842
<p>I'm programmatically adding ToolStripButton items to a context menu.</p> <p>That part is easy.</p> <pre><code>this.tsmiDelete.DropDownItems.Add("The text on the item."); </code></pre> <p>However, I also need to wire up the events so that when the user clicks the item something actually happens!</p> <p>How do I do this? The method that handles the click also needs to receive some sort of id or object that relates to the particular ToolStripButton that the user clicked.</p>
[ { "answer_id": 84909, "author": "Andy", "author_id": 3857, "author_profile": "https://Stackoverflow.com/users/3857", "pm_score": 3, "selected": true, "text": "ToolStripButton btn = new ToolStripButton(\"The text on the item.\");\nthis.tsmiDelete.DropDownItems.Add(btn);\nbtn.Click += new EventHandler(OnBtnClicked);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7837/" ]
84,847
<p>How do I create a self-signed certificate for code signing using tools from the Windows SDK?</p>
[ { "answer_id": 201277, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 10, "selected": true, "text": "makecert -r -pe -n \"CN=My CA\" -ss CA -sr CurrentUser ^\n -a sha256 -cy authority -sky signature -sv MyCA.pvk MyCA.cer\n" }, { "answer_id": 16027204, "author": "Dan Kegel", "author_id": 1539692, "author_profile": "https://Stackoverflow.com/users/1539692", "pm_score": 5, "selected": false, "text": "certutil -addstore Root Demo_CA.cer\n" }, { "answer_id": 47144138, "author": "GorvGoyl", "author_id": 3073272, "author_profile": "https://Stackoverflow.com/users/3073272", "pm_score": 5, "selected": false, "text": "D:/" }, { "answer_id": 51443366, "author": "chaami", "author_id": 2647222, "author_profile": "https://Stackoverflow.com/users/2647222", "pm_score": 7, "selected": false, "text": "New-SelfSignedCertificate -DnsName email@yourdomain.com -Type CodeSigning -CertStoreLocation cert:\\CurrentUser\\My\n" }, { "answer_id": 71770052, "author": "Server Overflow", "author_id": 46207, "author_profile": "https://Stackoverflow.com/users/46207", "pm_score": 0, "selected": false, "text": "prompt $\necho off\ncls\n\ncopy \"my.exe\" \"my.bak.exe\"\n\n\"c:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22000.0\\x64\\signtool.exe\" sign /fd SHA256 /f MyCertificate.pfx /p MyPassword My.exe\n\npause \n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8446/" ]
84,882
<p>This is a pretty simple question, at least it seems like it should be, about sudo permissions in Linux.</p> <p>There are a lot of times when I just want to append something to <code>/etc/hosts</code> or a similar file but end up not being able to because both <code>&gt;</code> and <code>&gt;&gt;</code> are not allowed, even with root.</p> <p>Is there someway to make this work without having to <code>su</code> or <code>sudo su</code> into root?</p>
[ { "answer_id": 84898, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 4, "selected": false, "text": "sudo sh -c \"echo 127.0.0.1 localhost >> /etc/hosts\"\n" }, { "answer_id": 84899, "author": "Matt P", "author_id": 14230, "author_profile": "https://Stackoverflow.com/users/14230", "pm_score": 8, "selected": false, "text": "sudo sh -c \"echo 'something' >> /etc/privilegedfile\"\n" }, { "answer_id": 84914, "author": "Incident", "author_id": 11613, "author_profile": "https://Stackoverflow.com/users/11613", "pm_score": 5, "selected": false, "text": "sudo sh -c \"echo 'something' >> /etc/privilegedFile\"\n" }, { "answer_id": 84921, "author": "agnul", "author_id": 6069, "author_profile": "https://Stackoverflow.com/users/6069", "pm_score": 4, "selected": false, "text": "sudo sh -c \"echo >> somefile\"\n" }, { "answer_id": 550808, "author": "Yoo", "author_id": 37664, "author_profile": "https://Stackoverflow.com/users/37664", "pm_score": 11, "selected": true, "text": "tee --append" }, { "answer_id": 21764479, "author": "msanford", "author_id": 114900, "author_profile": "https://Stackoverflow.com/users/114900", "pm_score": 4, "selected": false, "text": "sudo bash -c \"cat <<EOIPFW >> /etc/ipfw.conf\n<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n\n<plist version=\\\"1.0\\\">\n <dict>\n <key>Label</key>\n <string>com.company.ipfw</string>\n <key>Program</key>\n <string>/sbin/ipfw</string>\n <key>ProgramArguments</key>\n <array>\n <string>/sbin/ipfw</string>\n <string>-q</string>\n <string>/etc/ipfw.conf</string>\n </array>\n <key>RunAtLoad</key>\n <true></true>\n </dict>\n</plist>\nEOIPFW\"\n" }, { "answer_id": 22517844, "author": "Vytenis Bivainis", "author_id": 815741, "author_profile": "https://Stackoverflow.com/users/815741", "pm_score": 3, "selected": false, "text": "tee" }, { "answer_id": 26023336, "author": "hololeap", "author_id": 983883, "author_profile": "https://Stackoverflow.com/users/983883", "pm_score": 3, "selected": false, "text": "~/.bashrc" }, { "answer_id": 41785490, "author": "pixistix", "author_id": 7451883, "author_profile": "https://Stackoverflow.com/users/7451883", "pm_score": -1, "selected": false, "text": "cat >>" }, { "answer_id": 46251017, "author": "Fthi.a.Abadi", "author_id": 3135632, "author_profile": "https://Stackoverflow.com/users/3135632", "pm_score": -1, "selected": false, "text": "echo \"export CATALINA_HOME=\"/opt/tomcat9\"\" >> /etc/environment\n" }, { "answer_id": 50003244, "author": "Noam Manos", "author_id": 658497, "author_profile": "https://Stackoverflow.com/users/658497", "pm_score": 2, "selected": false, "text": "sudo sed -i \"\\$ a $NEW_IP\\t\\t$NEW_HOST.domain.local\\t$NEW_HOST\" /etc/hosts\n" }, { "answer_id": 51053054, "author": "Michael Goldshteyn", "author_id": 473798, "author_profile": "https://Stackoverflow.com/users/473798", "pm_score": 2, "selected": false, "text": "sponge" }, { "answer_id": 64048847, "author": "abkrim", "author_id": 736872, "author_profile": "https://Stackoverflow.com/users/736872", "pm_score": 3, "selected": false, "text": "sudo tee -a /path/file/to/create_with_text > /dev/null <<EOT \nline 1\nline 2\nline 3\nEOT\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9908/" ]
84,885
<p>Wondering if anybody out there has any success in using the JDEdwards XMLInterop functionality. I've been using it for a while (with a simple PInvoke, will post code later). I'm looking to see if there's a better and/or more robust way.</p> <p>Thanks.</p>
[ { "answer_id": 154634, "author": "Jon Dewees", "author_id": 1365, "author_profile": "https://Stackoverflow.com/users/1365", "pm_score": 4, "selected": true, "text": "namespace YourNameSpace\n" }, { "answer_id": 19598192, "author": "nkuebelbeck", "author_id": 411490, "author_profile": "https://Stackoverflow.com/users/411490", "pm_score": 1, "selected": false, "text": "PSThread.dll\nicudt32.dll\nicui18n.dll\nicuuc.dll\njdel.dll\njdeunicode.dll\nlibeay32.dll\nmsvcp71.dll\nssleay32.dll\nustdio.dll\nxmlinterop.dll\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1365/" ]
84,912
<p>Making a web page display correctly im all major browsers today is a very time consuming task.</p> <p>Is there a easy way to make a CSS style that looks identical in every browser? Or at least do you have some tips to make this work easier?</p>
[ { "answer_id": 84975, "author": "Toby Mills", "author_id": 12377, "author_profile": "https://Stackoverflow.com/users/12377", "pm_score": 3, "selected": false, "text": "<!--[if lte IE 6]>\n<link href=\"/css/eqtr_ie6.css\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->\n" }, { "answer_id": 84977, "author": "Twan", "author_id": 6702, "author_profile": "https://Stackoverflow.com/users/6702", "pm_score": 0, "selected": false, "text": "$sHTML .= \"\\t\\t<LINK rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"\".$sURLCSS.$sStyle.\"\\\" />\\n\";\nif (file_exists($sPathCSS.$sFileStyle.\"_\".BROWSER_AGENT.\".\".$sExtension))\n $sHTML .= \"\\t\\t<LINK rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"\".$sURLCSS.$sFileStyle.\"_\".BROWSER_AGENT.\".\".$sExtension.\"\\\" />\\n\";\nif (file_exists($sPathCSS.$sFileStyle.\"_\".BROWSER_AGENT.\"_\".BROWSER_VERSION.\".\".$sExtension))\n $sHTML .= \"\\t\\t<LINK rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"\".$sURLCSS.$sFileStyle.\"_\".BROWSER_AGENT.\"_\".BROWSER_VERSION.\".\".$sExtension.\"\\\" />\\n\";\n" }, { "answer_id": 85112, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 2, "selected": false, "text": "<head>\n <link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/yui/grids/base-min.css\" />\n <link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/yui/grids/grids.css\" />\n <link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/screen.foo.css\" />\n <link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"styles/print.foo.css\" />" }, { "answer_id": 85817, "author": "jelmer", "author_id": 16499, "author_profile": "https://Stackoverflow.com/users/16499", "pm_score": 2, "selected": false, "text": "*{margin: 0; padding: 0}\n" }, { "answer_id": 210736, "author": "Jethro Larson", "author_id": 22425, "author_profile": "https://Stackoverflow.com/users/22425", "pm_score": -1, "selected": false, "text": "*{display:none}\n" }, { "answer_id": 395676, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<!DOCTYPE html>\n<html>\n<head>\n <style>* { background: #fff }</style>\n</head>\n<body></body>\n</html>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14635/" ]
84,932
<p>I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script <code>$0</code> varies and sometimes contains the <code>fullpath+filename</code> and sometimes just <code>filename</code>. Because the working directory can vary as well I can't think of a way to reliably get the <code>fullpath+filename</code> of the script.</p> <p>Anyone got a solution?</p>
[ { "answer_id": 84959, "author": "Ovid", "author_id": 8003, "author_profile": "https://Stackoverflow.com/users/8003", "pm_score": 7, "selected": false, "text": "use Cwd 'abs_path';\nprint abs_path($0);\n" }, { "answer_id": 84973, "author": "Sean", "author_id": 4919, "author_profile": "https://Stackoverflow.com/users/4919", "pm_score": 3, "selected": false, "text": "$ENV{'SCRIPT_NAME'}\n" }, { "answer_id": 84982, "author": "bmdhacks", "author_id": 14032, "author_profile": "https://Stackoverflow.com/users/14032", "pm_score": 4, "selected": false, "text": "#!/usr/bin/perl\nuse FindBin;\n\n$0 = \"stealth\";\nprint \"The actual path to this is: $FindBin::Bin/$FindBin::Script\\n\";\n" }, { "answer_id": 85037, "author": "Benjamin W. Smith", "author_id": 1068060, "author_profile": "https://Stackoverflow.com/users/1068060", "pm_score": 4, "selected": false, "text": "use Cwd qw(abs_path);\nmy $path = abs_path($0);\nprint \"$path\\n\";\n" }, { "answer_id": 85070, "author": "Mark", "author_id": 16363, "author_profile": "https://Stackoverflow.com/users/16363", "pm_score": 5, "selected": false, "text": "use File::Spec;\nFile::Spec->rel2abs( __FILE__ );\n" }, { "answer_id": 85098, "author": "moritz", "author_id": 14132, "author_profile": "https://Stackoverflow.com/users/14132", "pm_score": 2, "selected": false, "text": "rel2abs()" }, { "answer_id": 85264, "author": "wnoise", "author_id": 15464, "author_profile": "https://Stackoverflow.com/users/15464", "pm_score": 3, "selected": false, "text": "__FILE__" }, { "answer_id": 90721, "author": "Drew Stephens", "author_id": 17339, "author_profile": "https://Stackoverflow.com/users/17339", "pm_score": 9, "selected": true, "text": "$0" }, { "answer_id": 90769, "author": "Eric Wilhelm", "author_id": 11580, "author_profile": "https://Stackoverflow.com/users/11580", "pm_score": 3, "selected": false, "text": "$0" }, { "answer_id": 5516160, "author": "Yong Li", "author_id": 687946, "author_profile": "https://Stackoverflow.com/users/687946", "pm_score": 1, "selected": false, "text": "my $thisfile = $1 if $0 =~\n/\\\\([^\\\\]*)$|\\/([^\\/]*)$/;\n\nprint \"You are running $thisfile\nnow.\\n\";\n" }, { "answer_id": 6997006, "author": "Yordan Georgiev", "author_id": 65706, "author_profile": "https://Stackoverflow.com/users/65706", "pm_score": 0, "selected": false, "text": "use strict ; use warnings ; use Cwd 'abs_path';\n sub ResolveMyProductBaseDir { \n\n # Start - Resolve the ProductBaseDir\n #resolve the run dir where this scripts is placed\n my $ScriptAbsolutPath = abs_path($0) ; \n #debug print \"\\$ScriptAbsolutPath is $ScriptAbsolutPath \\n\" ;\n $ScriptAbsolutPath =~ m/^(.*)(\\\\|\\/)(.*)\\.([a-z]*)/; \n $RunDir = $1 ; \n #debug print \"\\$1 is $1 \\n\" ;\n #change the \\'s to /'s if we are on Windows\n $RunDir =~s/\\\\/\\//gi ; \n my @DirParts = split ('/' , $RunDir) ; \n for (my $count=0; $count < 4; $count++) { pop @DirParts ; }\n my $ProductBaseDir = join ( '/' , @DirParts ) ; \n # Stop - Resolve the ProductBaseDir\n #debug print \"ResolveMyProductBaseDir $ProductBaseDir is $ProductBaseDir \\n\" ; \n return $ProductBaseDir ; \n } #eof sub \n" }, { "answer_id": 13566423, "author": "mkc", "author_id": 1853620, "author_profile": "https://Stackoverflow.com/users/1853620", "pm_score": 1, "selected": false, "text": "#!/usr/bin/perl -w\nuse strict;\n\n\nmy $path = $0;\n$path =~ s/\\.\\///g;\nif ($path =~ /\\//){\n if ($path =~ /^\\//){\n $path =~ /^((\\/[^\\/]+){1,}\\/)[^\\/]+$/;\n $path = $1;\n }\n else {\n $path =~ /^(([^\\/]+\\/){1,})[^\\/]+$/;\n my $path_b = $1;\n my $path_a = `pwd`;\n chop($path_a);\n $path = $path_a.\"/\".$path_b;\n }\n }\nelse{\n $path = `pwd`;\n chop($path);\n $path.=\"/\";\n }\n$path =~ s/\\/\\//\\//g;\n\n\n\nprint \"\\n$path\\n\";\n" }, { "answer_id": 17735548, "author": "Matt", "author_id": 2597514, "author_profile": "https://Stackoverflow.com/users/2597514", "pm_score": 3, "selected": false, "text": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nuse File::Spec;\nuse File::Basename;\n\nmy $dir = dirname(File::Spec->rel2abs(__FILE__));\n" }, { "answer_id": 20349041, "author": "user3061015", "author_id": 3061015, "author_profile": "https://Stackoverflow.com/users/3061015", "pm_score": -1, "selected": false, "text": "$^X" }, { "answer_id": 20565937, "author": "Jonathan", "author_id": 271450, "author_profile": "https://Stackoverflow.com/users/271450", "pm_score": 0, "selected": false, "text": "__FILE__" }, { "answer_id": 21605869, "author": "Putnik", "author_id": 1013183, "author_profile": "https://Stackoverflow.com/users/1013183", "pm_score": 0, "selected": false, "text": "my $self = `pwd`;\nchomp $self;\n$self .='/'.$1 if $0 =~/([^\\/]*)$/; #keep the filename only\nprint \"self=$self\\n\";\n" }, { "answer_id": 23149908, "author": "DavidGamba", "author_id": 1601989, "author_profile": "https://Stackoverflow.com/users/1601989", "pm_score": 1, "selected": false, "text": "dirname(__FILE__)" }, { "answer_id": 24515046, "author": "daniel souza", "author_id": 1226168, "author_profile": "https://Stackoverflow.com/users/1226168", "pm_score": 2, "selected": false, "text": "$0 =~ m/(.+)[\\/\\\\](.+)$/;\nprint \"full path: $1, file name: $2\\n\";\n" }, { "answer_id": 25663214, "author": "Elmar", "author_id": 4007562, "author_profile": "https://Stackoverflow.com/users/4007562", "pm_score": 0, "selected": false, "text": " my $callpath = $0;\n my $pwd = `pwd`; chomp($pwd);\n\n # if called relative -> add pwd in front\n if ($callpath !~ /^\\//) { $callpath = $pwd.\"/\".$callpath; } \n\n # do the cleanup\n $callpath =~ s!^\\./!!; # starts with ./ -> drop\n $callpath =~ s!/\\./!/!g; # /./ -> /\n $callpath =~ s!/\\./!/!g; # /./ -> / (twice)\n\n $callpath =~ s!/[^/]+/\\.\\./!/!g; # /xxx/../ -> /\n $callpath =~ s!/[^/]+/\\.\\./!/!g; # /xxx/../ -> / (twice)\n\n my $calldir = $callpath;\n $calldir =~ s/(.*)\\/([^\\/]+)/$1/;\n" }, { "answer_id": 52944919, "author": "drjumper", "author_id": 5116399, "author_profile": "https://Stackoverflow.com/users/5116399", "pm_score": 0, "selected": false, "text": "sub get_script_full_path {\n use File::Basename;\n use File::Spec;\n use Cwd qw(chdir cwd);\n my $curr_dir = cwd();\n chdir(dirname($0));\n my $dir = $ENV{PWD};\n chdir( $curr_dir);\n return File::Spec->catfile($dir, basename($0));\n}\n" }, { "answer_id": 58417063, "author": "user3228609", "author_id": 3228609, "author_profile": "https://Stackoverflow.com/users/3228609", "pm_score": 0, "selected": false, "text": "dirname" }, { "answer_id": 63550144, "author": "user3673", "author_id": 871821, "author_profile": "https://Stackoverflow.com/users/871821", "pm_score": 0, "selected": false, "text": "use File::Basename;\nuse Cwd 'abs_path';\nprint dirname(abs_path(__FILE__)) ;\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16331/" ]
84,968
<p>If I open a file in Design View (web form), I get intellisense for my display code, but not my script code.. If I open with source code editor I, occasionally, get intellisense within the script tags. </p> <p>Anyone know how to get intellisense working all of the time for all of my code? </p> <p>Been living with this one for a long time.</p>
[ { "answer_id": 85583, "author": "devlord", "author_id": 16454, "author_profile": "https://Stackoverflow.com/users/16454", "pm_score": 1, "selected": false, "text": "<script runat=\"server\">" }, { "answer_id": 86256, "author": "madcolor", "author_id": 13954, "author_profile": "https://Stackoverflow.com/users/13954", "pm_score": 2, "selected": true, "text": "<%@ Page Language=\"C#\" MasterPageFile=\"~/common/masterpages/MasterPage.master\" %>" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
84,992
<p>I'm trying to register an externally hosted SQL 2000 server through Enterprise Manager which isn't on the default port and I can't see anywhere to change it within Enterprise Manager.</p> <p>So, the question is, how do I connect to the database if:</p> <p>I.P. Address is 123.456.789 (example)</p> <p>Port is 1334</p>
[ { "answer_id": 86031, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "\\\\[instance]" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
84,995
<p>I'm looking for a way to stream a PDF file from my server to the browser using .NET 2.0 (in binary).</p> <p>I'm trying to grab an existing PDF file from a server path and push that up as binary to the browser.</p>
[ { "answer_id": 85002, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 1, "selected": false, "text": "Response.OutputStream" }, { "answer_id": 85053, "author": "foxxtrot", "author_id": 10369, "author_profile": "https://Stackoverflow.com/users/10369", "pm_score": 2, "selected": false, "text": "Response.ContentType = \"application/pdf\"" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/84995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2701/" ]
85,006
<p>I have loaded image into a new, initialized Oracle ORDImage object and am processing it by PL/SQL. I can read its properties, but cannot process it with the process() method. </p> <pre><code>vLocalImage ORDImage := ORDImage.init(); ... vLocalImage.source.localdata := PORTAL.wwdoc_admin.get_document_blob_content(pFile); vLocalImage.setProperties(); ... if vLocalImage.width &gt; lMaxWidth then vLocalImage.process('maxScale 534 401'); end if; </code></pre> <p>This should scale the image down, conserving aspect ratio, so that it is no more than 534 px wide and no more than 401 px high. </p> <p>However, I get the following error stack:</p> <pre><code>Internal error: ORA-29400: data cartridge error IMG-00710: unable to write to destination image ORA-01031: insufficient privileges </code></pre> <p>Trying other operations (like 'rotate 90') gives same errors.</p>
[ { "answer_id": 253114, "author": "Sten Vesterli", "author_id": 9363, "author_profile": "https://Stackoverflow.com/users/9363", "pm_score": 3, "selected": true, "text": " vNewImage ORDImage;\n...\n vLocalImage.processCopy('maxScale 534 401', vNewImage);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9363/" ]
85,019
<p>Google Maps used to do this bit where when you hit the &quot;Print&quot; link, what would be sent to the printer wasn't exactly what you had on the screen, but rather a differently-formatted version of mostly the same information.</p> <p>It appears that they've largely moved away from this concept (I guess people didn't understand it) and most websites have a &quot;print version&quot; of things like articles and so forth.</p> <p>But if you wanted to make a webpage such that a &quot;printer friendly&quot; version of the page is what gets sent to the printer without having to make a separate page for it, how would you do that?</p>
[ { "answer_id": 85061, "author": "skamradt", "author_id": 9217, "author_profile": "https://Stackoverflow.com/users/9217", "pm_score": 3, "selected": false, "text": "<link rel=\"stylesheet\" type=\"text/css\" href=\"print.css\" media=\"print, handheld\" />\n<link rel=\"stylesheet\" type=\"text/css\" href=\"screen.css\" media=\"screen\" />\n" }, { "answer_id": 85067, "author": "Toby Mills", "author_id": 12377, "author_profile": "https://Stackoverflow.com/users/12377", "pm_score": 1, "selected": false, "text": "<link href=\"css/print.css\" type=\"text/css\" rel=\"stylesheet\" media=\"print\" />" }, { "answer_id": 85087, "author": "Twan", "author_id": 6702, "author_profile": "https://Stackoverflow.com/users/6702", "pm_score": 0, "selected": false, "text": "if (!BOOL_PRINT)\n echo \"<TD class=\\\"tbl_teams_scroll_item\\\"><SPAN class=\\\"span_password_hidden\\\" id=\\\"span_password_{\\$team_id}\\\" onClick=\\\"RevealPassword('{\\$team_id}','{\\$password}');\\\"><xsl:value-of select=\\\"/PAGE/TEXTS/HIDDEN\\\" /></SPAN></TD>\\n\";\nelse\n echo \"TD class=\\\"tbl_teams_scroll_item\\\"><xsl:value-of select=\\\"PASSWORD\\\" /></TD>\\n\";\n" }, { "answer_id": 85107, "author": "JacquesB", "author_id": 7488, "author_profile": "https://Stackoverflow.com/users/7488", "pm_score": 2, "selected": false, "text": "@media" }, { "answer_id": 85110, "author": "dave", "author_id": 14355, "author_profile": "https://Stackoverflow.com/users/14355", "pm_score": 0, "selected": false, "text": " @media print {\n BODY { font-size: 10pt }\n }\n @media screen {\n BODY { font-size: 12pt }\n }\n @media screen, print {\n BODY { line-height: 1.2 }\n }\n" }, { "answer_id": 87095, "author": "Steve Perks", "author_id": 16124, "author_profile": "https://Stackoverflow.com/users/16124", "pm_score": 0, "selected": false, "text": "window.print()" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577/" ]
85,033
<p>I am wrapping a native C++ class, which has the following methods:</p> <pre><code>class Native { public: class Local { std::string m_Str; int m_Int; }; typedef std::vector&lt;Local&gt; LocalVec; typedef LocalVec::iterator LocalIter; LocalIter BeginLocals(); LocalIter EndLocals(); private: LocalVec m_Locals; }; </code></pre> <p>1) What is the ".NET way" of representing this same kind of interface? A single method returning an array&lt;>? Does the array&lt;> generic have iterators, so that I could implement BeginLocals() and EndLocals()? </p> <p>2) Should Local be declared as a <strong>value struct</strong> in the .NET wrapper?</p> <p>I'd really like to represent the wrapped class with a .NET flavor, but I'm very new to the managed world - and this type of information is frustrating to google for...</p>
[ { "answer_id": 85402, "author": "Philip Rieck", "author_id": 12643, "author_profile": "https://Stackoverflow.com/users/12643", "pm_score": 4, "selected": true, "text": " vector<int> a_vector;\n vector<int>::iterator a_iterator;\n for(int i= 0; i < 100; i++)\n {\n a_vector.push_back(i);\n }\n\n int total = 0;\n a_iterator = a_vector.begin();\n while( a_iterator != a_vector.end() ) {\n total += *a_iterator;\n a_iterator++;\n }\n" }, { "answer_id": 86875, "author": "Brian Stewart", "author_id": 3114, "author_profile": "https://Stackoverflow.com/users/3114", "pm_score": 0, "selected": false, "text": "public ref class Managed\n{\n public:\n ref class Local\n {\n String^ m_Str;\n int m_Int;\n };\n\n property const Local^ Locals[int]\n {\n const Local^ get(int Index)\n {\n // error checking here...\n return m_Locals[Index];\n }\n };\n\n private:\n List<Local^> m_Locals;\n};\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114/" ]
85,034
<p>I want to make a table in SqlServer that will add, on insert, a auto incremented primary key. This should be an autoincremented id similar to MySql auto_increment functionality. (Below)</p> <pre><code>create table foo ( user_id int not null auto_increment, name varchar(50) ) </code></pre> <p>Is there a way of doing this with out creating an insert trigger?</p>
[ { "answer_id": 85042, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 5, "selected": true, "text": "create table foo \n( \nuser_id int not null identity, \nname varchar(50) \n)\n" }, { "answer_id": 85858, "author": "Nasir", "author_id": 16522, "author_profile": "https://Stackoverflow.com/users/16522", "pm_score": 1, "selected": false, "text": "CREATE TABLE foo\n(\nuser_id int IDENTITY(1,1) NOT NULL,\nname varchar(50)\n)\n" }, { "answer_id": 86110, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 3, "selected": false, "text": "CREATE TABLE user\n(\n TheKey int IDENTITY(1,1) PRIMARY KEY,\n Name varchar(50)\n)\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12942/" ]
85,036
<p>I need to manually migrate modified stored procedures from a DEV SQL Server 2005 database instance to a TEST instance. Except for the changes I'm migrating, the databases have the same schemas. How can I quickly identify which stored procedures have been modified in the DEV database for migration to the TEST instance?</p> <p>I assume I can write a query against some of the system tables to view database objects of type stored procedure, sorting by some sort of last modified or compiled data, but I'm not sure. Maybe there is some sort of free utility someone can point me to.</p>
[ { "answer_id": 85084, "author": "RBS", "author_id": 14299, "author_profile": "https://Stackoverflow.com/users/14299", "pm_score": 0, "selected": false, "text": "SELECT name\n FROM sys.objects\n WHERE type = 'P'\n AND DATEDIFF(D,modify_date, GETDATE()) < 7\n" }, { "answer_id": 85096, "author": "Jason Stevenson", "author_id": 13368, "author_profile": "https://Stackoverflow.com/users/13368", "pm_score": 4, "selected": false, "text": "SELECT name\nFROM sys.objects\nWHERE type = 'P'\n AND DATEDIFF(D,modify_date, GETDATE()) < X\n" }, { "answer_id": 85111, "author": "RBS", "author_id": 14299, "author_profile": "https://Stackoverflow.com/users/14299", "pm_score": 1, "selected": false, "text": "USE AdventureWorks2008;\n\nGO\n\nSELECT SprocName=name, create_date, modify_date\n\nFROM sys.objects\n\nWHERE type = 'P' \n\nAND name = 'uspUpdateEmployeeHireInfo'\n\nGO\n" }, { "answer_id": 85150, "author": "Tom H", "author_id": 5696608, "author_profile": "https://Stackoverflow.com/users/5696608", "pm_score": 0, "selected": false, "text": "SELECT name\nFROM sys.objects\nWHERE modify_date > @cutoffdate\n" }, { "answer_id": 85191, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 7, "selected": true, "text": "select name,create_date,modify_date\nfrom sys.procedures\norder by modify_date desc\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16137/" ]
85,046
<p>Are there any good books or website that go over creating a <code>JTable</code>? I want to make one column editable. I would like to actually put a inherited <code>JCheckBox</code> component (that we created here) into one of the table columns instead of just having the table put <code>JCheckBox</code> in based on it being an editable <code>boolean</code> field.</p> <p>I have the <a href="https://rads.stackoverflow.com/amzn/click/com/0201914670" rel="nofollow noreferrer" rel="nofollow noreferrer">JFC Swing Tutorial Second Edition</a> book but I just would like to know if there are other examples I could look at and learn how to deal with the tables better. The book seems to just take the java 'trail' online and put it in the book.</p> <p>I am re-reading the stuff though, just curious if anyone has found something that might help out more.</p>
[ { "answer_id": 105005, "author": "Richard Walton", "author_id": 15075, "author_profile": "https://Stackoverflow.com/users/15075", "pm_score": 0, "selected": false, "text": "Package javax.swing.table" }, { "answer_id": 105380, "author": "morsch", "author_id": 19256, "author_profile": "https://Stackoverflow.com/users/19256", "pm_score": 6, "selected": true, "text": "isCellEditable" }, { "answer_id": 117016, "author": "ShawnD", "author_id": 6186, "author_profile": "https://Stackoverflow.com/users/6186", "pm_score": 1, "selected": false, "text": "JTable" }, { "answer_id": 39328305, "author": "Maxwell Cheng", "author_id": 6206976, "author_profile": "https://Stackoverflow.com/users/6206976", "pm_score": 0, "selected": false, "text": "public ArrayList<XXXDO> tbmData = new ArrayList<XXXDO>(); //arraylist for data in table\n\n@Override\npublic boolean isCellEditable(int row, int col) {\n if (col == 4) {\n return true;\n } else {\n return false;\n }\n}\n\n@Override\npublic void setValueAt(Object value, int row, int col) {\n if ((row >= 0) && (row < this.tbmData.size()) && (col >= 0) && (col < this.colNm.length)) {\n if (col == 4) {\n tbmData.get(row).col4= (String) value;\n }\n fireTableCellUpdated(row, col);\n } else {\n }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14009/" ]
85,051
<p>Assuming network access is sporadic with no central server, what would be the best way to use git to keep three or more branches in sync? Is there a way to extract just my deltas, email those, and merge them on the other end?</p>
[ { "answer_id": 85079, "author": "Jim Puls", "author_id": 6010, "author_profile": "https://Stackoverflow.com/users/6010", "pm_score": 3, "selected": false, "text": "git-format-patch" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16203/" ]
85,058
<p>I see <a href="http://www.is-research.de/info/vmlanguages/index.html" rel="noreferrer">here</a> that there are a load of languages aside from Java that run on the JVM. I'm a bit confused about the whole concept of other languages running in the JVM. So:</p> <p>What is the advantage in having other languages for the JVM?</p> <p>What is required (in high level terms) to write a language/compiler for the JVM? </p> <p>How do you write/compile/run code in a language (other than Java) in the JVM?</p> <hr> <p><strong>EDIT:</strong> There were 3 follow up questions (originally comments) that were answered in the accepted answer. They are reprinted here for legibility:</p> <p>How would an app written in, say, JPython, interact with a Java app? </p> <p>Also, Can that JPython application use any of the JDK functions/objects?? </p> <p>What if it was Jaskell code, would the fact that it is a functional language not make it incompatible with the JDK?</p>
[ { "answer_id": 86201, "author": "toluju", "author_id": 12457, "author_profile": "https://Stackoverflow.com/users/12457", "pm_score": 6, "selected": true, "text": "from java.net import URL\nu = URL('http://jython.org')\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/142/" ]
85,085
<p>I've got an RMI call defined as:</p> <pre><code>public void remoteGetCustomerNameNumbers(ArrayList&lt;String&gt; customerNumberList, ArrayList&lt;String&gt; customerNameList) throws java.rmi.RemoteException; </code></pre> <p>The function does a database lookup and populates the two ArrayLists. The calling function gets nothing. I believe this works with Vector types.</p> <p>Do I need to use the Vector, or is there a way to get this to work without making two calls. I've got some other ideas that I'd probably use, like returning a key/value pair, but I'd like to know if I can get this to work.</p> <p>Update:<br/> I would accept all of the answers given so far if I could. I hadn't known the network cost, so It makes sense to rework the function to return a LinkedHashMap instead of the two ArrayLists.</p>
[ { "answer_id": 86847, "author": "BCunningham", "author_id": 7689, "author_profile": "https://Stackoverflow.com/users/7689", "pm_score": 1, "selected": false, "text": "public ArrayList<String> getCustomerNames() throws java.rmi.RemoteException;\n\npublic ArrayList<String> getCustomerNumbers() throws java.rmi.RemoteException;\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16345/" ]
85,091
<p>OK, this begins to drive me crazy. I have an asp.net webapp. Pretty straightforward, most of the code in the .aspx.vb, and a few classes in App_Code.</p> <p>The problem, which has begun to occur only today (even though most of the code was already written), is that once in a while, I have this error message :</p> <blockquote> <p>Error BC30002: Type ‘XXX’ is not defined</p> </blockquote> <p>The error occurs about every time I modify the files in the App_Code folder. EDIT : OK, this happens also if I don't touch anything for a while then refresh the page. I'm still trying to figure out exactly how to trigger this error.</p> <p>I just have to wait a little bit without touching anything, then refresh the page and it works, but it's very annoying.</p> <p>So I searched a little bit, but nothing came up except imports missing. Any idea ?</p>
[ { "answer_id": 156933, "author": "thomasb", "author_id": 6776, "author_profile": "https://Stackoverflow.com/users/6776", "pm_score": 4, "selected": true, "text": "Imports CMS\n\nSub Whatever()\n Dim a as new Arbo.MyObject() ' Arbo is a namespace inside CMS\n Dim b as new Util.MyOtherObject() ' Util is a namespace inside Util\nEnd Sub\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6776/" ]
85,116
<p>I want the server to always serve dates in UTC in the HTML, and have JavaScript on the client site convert it to the user's local timezone.</p> <p>Bonus if I can output in the user's locale date format.</p>
[ { "answer_id": 85161, "author": "japollock", "author_id": 1210318, "author_profile": "https://Stackoverflow.com/users/1210318", "pm_score": -1, "selected": false, "text": "usersLocalTime = new Date();\n" }, { "answer_id": 85213, "author": "dave", "author_id": 14355, "author_profile": "https://Stackoverflow.com/users/14355", "pm_score": 2, "selected": false, "text": "new Date().getTimezoneOffset();\n" }, { "answer_id": 85235, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 5, "selected": false, "text": "new Date().getTimezoneOffset()/60" }, { "answer_id": 85357, "author": "Mark", "author_id": 9303, "author_profile": "https://Stackoverflow.com/users/9303", "pm_score": 3, "selected": false, "text": "var myDate = new Date();\nvar tzo = (myDate.getTimezoneOffset()/60)*(-1);\n//get server date value here, the parseInvariant is from MS Ajax, you would need to do something similar on your own\nmyDate = new Date.parseInvariant('<%=DataCurrentDate%>', 'yyyyMMdd hh:mm:ss');\nmyDate.setHours(myDate.getHours() + tzo);\n//here you would have to get a handle to your span / div to set. again, I'm using MS Ajax's $get\nvar dateSpn = $get('dataDate');\ndateSpn.innerHTML = myDate.localeFormat('F');\n" }, { "answer_id": 85793, "author": "Már Örlygsson", "author_id": 16271, "author_profile": "https://Stackoverflow.com/users/16271", "pm_score": 2, "selected": false, "text": ".getTimezoneOffset()" }, { "answer_id": 86533, "author": "kch", "author_id": 13989, "author_profile": "https://Stackoverflow.com/users/13989", "pm_score": 9, "selected": true, "text": "Date" }, { "answer_id": 2830494, "author": "simianarmy", "author_id": 222367, "author_profile": "https://Stackoverflow.com/users/222367", "pm_score": 3, "selected": false, "text": "Date.strftime" }, { "answer_id": 23872920, "author": "theDmi", "author_id": 219187, "author_profile": "https://Stackoverflow.com/users/219187", "pm_score": 6, "selected": false, "text": "var m = moment(\"2013-02-08T09:30:26Z\");\n" }, { "answer_id": 32781372, "author": "hriziya", "author_id": 1005741, "author_profile": "https://Stackoverflow.com/users/1005741", "pm_score": 2, "selected": false, "text": "function getLocalDate(php_date) {\n var dt = new Date(php_date);\n var minutes = dt.getTimezoneOffset();\n dt = new Date(dt.getTime() + minutes*60000);\n return dt;\n}\n" }, { "answer_id": 41000624, "author": "Anja", "author_id": 1544659, "author_profile": "https://Stackoverflow.com/users/1544659", "pm_score": 2, "selected": false, "text": "language = request.META.get('HTTP_ACCEPT_LANGUAGE')\nreturn render(request, 'cssexy/index.html', { \"language\": language })\n" }, { "answer_id": 43863035, "author": "Jeremy Chone", "author_id": 686724, "author_profile": "https://Stackoverflow.com/users/686724", "pm_score": 4, "selected": false, "text": "var d = new Date(); \nd = new Date(d.getTime() - d.getTimezoneOffset() * 60000)\nvar yyyymmdd = t.toISOString().slice(0, 10); \n// 2017-05-09T08:24:26.581Z (but this is not UTC)\n" }, { "answer_id": 51259500, "author": "Codemaker", "author_id": 7103882, "author_profile": "https://Stackoverflow.com/users/7103882", "pm_score": 0, "selected": false, "text": "var date = (new Date(str)).toLocaleDateString(defaultlang, options);\n" }, { "answer_id": 54813917, "author": "Serg", "author_id": 1844247, "author_profile": "https://Stackoverflow.com/users/1844247", "pm_score": 3, "selected": false, "text": "// new Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]])\nvar serverDate = new Date(2018, 5, 30, 19, 13, 15); // just any date that comes from server\nvar serverDateStr = serverDate.toLocaleString(\"en-US\", {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n})\nvar userDate = new Date(serverDateStr + \" UTC\");\nvar locale = window.navigator.userLanguage || window.navigator.language;\n\nvar clientDateStr = userDate.toLocaleString(locale, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric'\n});\n\nvar clientDateTimeStr = userDate.toLocaleString(locale, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n});\n\nconsole.log(\"Server UTC date: \" + serverDateStr);\nconsole.log(\"User's local date: \" + clientDateStr);\nconsole.log(\"User's local date&time: \" + clientDateTimeStr);" }, { "answer_id": 67201763, "author": "Flavien Volken", "author_id": 532695, "author_profile": "https://Stackoverflow.com/users/532695", "pm_score": 3, "selected": false, "text": "const utcDate = new Date(Date.UTC(2020, 11, 20, 3, 23, 16, 738));\nconsole.log(new Intl.DateTimeFormat().format(utcDate));\n// expected output: \"21/04/2021\", my locale is Switzerland\n" }, { "answer_id": 71803712, "author": "Hans Bouwmeester", "author_id": 8005373, "author_profile": "https://Stackoverflow.com/users/8005373", "pm_score": 0, "selected": false, "text": "export const humanFriendlyDateStr = (iso8601) => {\n\n // Examples (using Node.js):\n\n // Get an ISO8601 date string using Date()\n // > new Date()\n // 2022-04-08T22:05:18.595Z\n\n // If it was earlier today, just show the time:\n // > humanFriendlyDateStr('2022-04-08T22:05:18.595Z')\n // '3:05 PM'\n\n // If it was during the past week, add the day:\n // > humanFriendlyDateStr('2022-04-07T22:05:18.595Z')\n // 'Thu 3:05 PM'\n\n // If it was more than a week ago, add the date\n // > humanFriendlyDateStr('2022-03-07T22:05:18.595Z')\n // '3/7, 2:05 PM'\n\n // If it was more than a year ago add the year\n // > humanFriendlyDateStr('2021-03-07T22:05:18.595Z')\n // '3/7/2021, 2:05 PM'\n\n // If it's sometime in the future return the full date+time:\n // > humanFriendlyDateStr('2023-03-07T22:05:18.595Z')\n // '3/7/2023, 2:05 PM'\n\n const datetime = new Date(Date.parse(iso8601))\n const now = new Date()\n const ageInDays = (now - datetime) / 86400000\n let str\n\n // more than 1 year old?\n if (ageInDays > 365) {\n str = datetime.toLocaleDateString([], {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n })\n // more than 1 week old?\n } else if (ageInDays > 7) {\n str = datetime.toLocaleDateString([], {\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n })\n // more than 1 day old?\n } else if (ageInDays > 1) {\n str = datetime.toLocaleDateString([], {\n weekday: 'short',\n hour: 'numeric',\n minute: 'numeric',\n })\n // some time today?\n } else if (ageInDays > 0) {\n str = datetime.toLocaleTimeString([], {\n timeStyle: 'short',\n })\n // in the future?\n } else {\n str = datetime.toLocaleDateString([], {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n })\n }\n return str\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
85,119
<p>I know you can do redirection based on the domain or path to rewrite the URI to point at a site-specific location and I've also seen some brutish <code>if</code> and <code>elif</code> statements for every site as shown in the following code, which I would like to avoid.</p> <pre class="lang-py prettyprint-override"><code>if site == 'site1': ... elif site == 'site2: ... </code></pre> <p>What are some good and clever ways of running multiple sites from a single, common Python web framework (i.e., Pylons, TurboGears, etc)?</p>
[ { "answer_id": 85134, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 5, "selected": true, "text": "Host" }, { "answer_id": 86705, "author": "Gabriel Ross", "author_id": 10751, "author_profile": "https://Stackoverflow.com/users/10751", "pm_score": 3, "selected": false, "text": "<VirtualHost 1.2.3.4>\n DocumentRoot /www/site1\n ServerName site1.com\n <Location />\n SetHandler python-program\n SetEnv DJANGO_SETTINGS_MODULE site1.settings\n PythonPath \"['/www'] + sys.path\"\n PythonDebug On\n PythonInterpreter site1\n </Location>\n</VirtualHost>\n\n<VirtualHost 1.2.3.4>\n DocumentRoot /www/site2\n ServerName site2.com\n <Location />\n SetHandler python-program\n SetEnv DJANGO_SETTINGS_MODULE site2.settings\n PythonPath \"['/www'] + sys.path\"\n PythonDebug On\n PythonInterpreter site2\n </Location>\n</VirtualHost>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4919/" ]
85,122
<p>On Windows I have a problem I never encountered on Unix. That is how to get a thread to sleep for less than one millisecond. On Unix you typically have a number of choices (sleep, usleep and nanosleep) to fit your needs. On Windows, however, there is only <em>Sleep</em> with millisecond granularity. </p> <p>On Unix, I can use the use the <code>select</code> system call to create a microsecond sleep which is pretty straightforward:</p> <pre><code>int usleep(long usec) { struct timeval tv; tv.tv_sec = usec/1000000L; tv.tv_usec = usec%1000000L; return select(0, 0, 0, 0, &amp;tv); } </code></pre> <p>How can I achieve the same on Windows?</p>
[ { "answer_id": 85143, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": -1, "selected": true, "text": "select" }, { "answer_id": 1448900, "author": "Hendrik", "author_id": 123411, "author_profile": "https://Stackoverflow.com/users/123411", "pm_score": 2, "selected": false, "text": "bool usleep(unsigned long usec)\n{\n struct timeval tv;\n fd_set dummy;\n SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);\n FD_ZERO(&dummy);\n FD_SET(s, &dummy);\n tv.tv_sec = usec / 1000000ul;\n tv.tv_usec = usec % 1000000ul;\n bool success = (0 == select(0, 0, 0, &dummy, &tv));\n closesocket(s);\n return success;\n}\n" }, { "answer_id": 11456112, "author": "Arno", "author_id": 1504523, "author_profile": "https://Stackoverflow.com/users/1504523", "pm_score": 3, "selected": false, "text": "NtQueryTimerResolution" }, { "answer_id": 31411628, "author": "Oskar Dahlberg", "author_id": 4858189, "author_profile": "https://Stackoverflow.com/users/4858189", "pm_score": 5, "selected": false, "text": "#include <Windows.h>\n\nstatic NTSTATUS(__stdcall *NtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval) = (NTSTATUS(__stdcall*)(BOOL, PLARGE_INTEGER)) GetProcAddress(GetModuleHandle(\"ntdll.dll\"), \"NtDelayExecution\");\nstatic NTSTATUS(__stdcall *ZwSetTimerResolution)(IN ULONG RequestedResolution, IN BOOLEAN Set, OUT PULONG ActualResolution) = (NTSTATUS(__stdcall*)(ULONG, BOOLEAN, PULONG)) GetProcAddress(GetModuleHandle(\"ntdll.dll\"), \"ZwSetTimerResolution\");\n\nstatic void SleepShort(float milliseconds) {\n static bool once = true;\n if (once) {\n ULONG actualResolution;\n ZwSetTimerResolution(1, true, &actualResolution);\n once = false;\n }\n\n LARGE_INTEGER interval;\n interval.QuadPart = -1 * (int)(milliseconds * 10000.0f);\n NtDelayExecution(false, &interval);\n}\n" }, { "answer_id": 33448417, "author": "rauprog", "author_id": 4798975, "author_profile": "https://Stackoverflow.com/users/4798975", "pm_score": 0, "selected": false, "text": "while (timer1 < 100 microseconds) {\nsleep(0);\n}\n\nif (timer2 >=100 microseconds) {\nmove projectile one pixel\n}\n\n//Rest of code in iteration here\n" }, { "answer_id": 43564734, "author": "Ian Boyd", "author_id": 12597, "author_profile": "https://Stackoverflow.com/users/12597", "pm_score": 1, "selected": false, "text": "void SpinOnce(ref Int32 spin)\n{\n /*\n SpinOnce is called each time we need to wait. \n But the action it takes depends on how many times we've been spinning:\n\n 1..12 spins: spin 2..4096 cycles\n 12..32: call SwitchToThread (allow another thread ready to go on time core to execute)\n over 32 spins: Sleep(0) (give up the remainder of our timeslice to any other thread ready to run, also allows APC and I/O callbacks)\n */\n spin += 1;\n\n if (spin > 32)\n Sleep(0); //give up the remainder of our timeslice\n else if (spin > 12)\n SwitchTothread(); //allow another thread on our CPU to have the remainder of our timeslice\n else\n {\n int loops = (1 << spin); //1..12 ==> 2..4096\n while (loops > 0)\n loops -= 1;\n }\n}\n" }, { "answer_id": 72823146, "author": "sir-pinecone", "author_id": 134027, "author_profile": "https://Stackoverflow.com/users/134027", "pm_score": 0, "selected": false, "text": "CreateWaitableTimerExW" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6508/" ]
85,137
<p>Say I have a class named Frog, it looks like:</p> <pre><code>public class Frog { public int Location { get; set; } public int JumpCount { get; set; } public void OnJump() { JumpCount++; } } </code></pre> <p>I need help with 2 things:</p> <ol> <li>I want to create an event named Jump in the class definition.</li> <li>I want to create an instance of the Frog class, and then create another method that will be called when the Frog jumps.</li> </ol>
[ { "answer_id": 85188, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 7, "selected": true, "text": "public event EventHandler Jump;\npublic void OnJump()\n{\n EventHandler handler = Jump;\n if (null != handler) handler(this, EventArgs.Empty);\n}\n" }, { "answer_id": 54242833, "author": "Tezra", "author_id": 6893866, "author_profile": "https://Stackoverflow.com/users/6893866", "pm_score": 3, "selected": false, "text": "?." } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
85,147
<p>I've never used any of the .NET generics in my work, but I understand that they are fairly popular. Does anyone have any good links or book suggestions for learning them? As a bonus; I only vaguely understand what .NET generic collections are and what they do...does anyone have any practical examples of how they might be used to greater advantage than the normal collections in .NET?</p>
[ { "answer_id": 85249, "author": "William Yeung", "author_id": 16371, "author_profile": "https://Stackoverflow.com/users/16371", "pm_score": -1, "selected": false, "text": "public T GetValue<T>() {\n return (T) ...;\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13776/" ]
85,159
<p>Is there any way to parse a string in the format HH:MM into a Date (or other) object using the standard libraries?</p> <p>I know that I can parse something like "9/17/2008 10:30" into a Date object using</p> <pre><code>var date:Date = new Date(Date.parse("9/17/2008 10:30"); </code></pre> <p>But I want to parse just 10:30 by itself. The following code will not work.</p> <pre><code>var date:Date = new Date(Date.parse("10:30"); </code></pre> <p>I know I can use a custom RegEx to do this fairly easily, but it seems like this should be possible using the existing Flex API.</p>
[ { "answer_id": 87125, "author": "mikechambers", "author_id": 10232, "author_profile": "https://Stackoverflow.com/users/10232", "pm_score": 2, "selected": false, "text": "var str:String = \"9/17/2008 10:30\"\n\nvar items:Array = str.split(\" \");\nvar dateElements:Array = items[0].split(\"/\");\nvar timeElements:Array = items[1].split(\":\");\n\nvar n:Date = new Date(dateElements[2],\n dateElements[0],\n dateElements[1].\n timeElements[0],\n timeElements[1]);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1247/" ]
85,181
<p>This is pretty weird.</p> <p>I have my Profiler open and it obviously shows that a stored procedure is called. I open the database and the SP list, but the SP doesn't exist. However, there's another SP whose name is the same except it has a prefix 'x'</p> <p>Is SQL Server 2005 mapping the SP name to a different one for security purposes?</p> <p>EDIT: I found out it's a Synonym, whatever that is. </p>
[ { "answer_id": 85341, "author": "Kevin Crumley", "author_id": 1818, "author_profile": "https://Stackoverflow.com/users/1818", "pm_score": 4, "selected": true, "text": "select *\nfrom sys.objects\nwhere name = 'THE_NAME_YOU_WANT'\n" }, { "answer_id": 6598930, "author": "Amit Sharma", "author_id": 831758, "author_profile": "https://Stackoverflow.com/users/831758", "pm_score": 1, "selected": false, "text": "select * from sys.objects where name = 'name of stored procedure'\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10088/" ]
85,183
<p>I have an object that implements IDisposable that is registered with the Windsor Container and I would like to dispose of it so it's Dispose method is called and next time Resolve is called it fetches a new instance.</p> <p>Does </p> <pre><code>container.Release(obj); </code></pre> <p>automatically call Dispose() immediately? Or do I need to do</p> <pre><code>obj.Dispose(); container.Release(obj); </code></pre> <p>Couldn't find anything in the documentation on what exactly Release does</p> <p><strong>EDIT:</strong> See my answer below for the results of tests I ran. Now the question becomes, how do I force the container to release an instance of a component with a singleton lifecycle? This only needs to be done in one place and writing a custom lifecycle seems far too heavyweight, is there no built in way of doing it?</p>
[ { "answer_id": 85498, "author": "Philip Rieck", "author_id": 12643, "author_profile": "https://Stackoverflow.com/users/12643", "pm_score": 2, "selected": false, "text": "using(ISomeService service = container.Resolve<ISomeService>())\n{\n // Do stuff here\n // service.Dispose is automatically called \n}\n" }, { "answer_id": 85820, "author": "George Mauer", "author_id": 5056, "author_profile": "https://Stackoverflow.com/users/5056", "pm_score": 1, "selected": false, "text": "Container.Release()" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
85,190
<p>Consider:</p> <pre><code>List&lt;String&gt; someList = new ArrayList&lt;String&gt;(); // add "monkey", "donkey", "skeleton key" to someList </code></pre> <pre><code>for (String item : someList) { System.out.println(item); } </code></pre> <p>What would the equivalent <code>for</code> loop look like without using the <em>for each</em> syntax?</p>
[ { "answer_id": 85206, "author": "nsayer", "author_id": 13757, "author_profile": "https://Stackoverflow.com/users/13757", "pm_score": 11, "selected": true, "text": "for (Iterator<String> i = someIterable.iterator(); i.hasNext();) {\n String item = i.next();\n System.out.println(item);\n}\n" }, { "answer_id": 85209, "author": "toluju", "author_id": 12457, "author_profile": "https://Stackoverflow.com/users/12457", "pm_score": 6, "selected": false, "text": "Iterator<String> iterator = someList.iterator();\n\nwhile (iterator.hasNext()) {\n String item = iterator.next();\n System.out.println(item);\n}\n" }, { "answer_id": 85220, "author": "Hank", "author_id": 7610, "author_profile": "https://Stackoverflow.com/users/7610", "pm_score": 4, "selected": false, "text": "for(Iterator<String> sit = someList.iterator(); sit.hasNext(); ) {\n System.out.println(sit.next());\n}\n" }, { "answer_id": 85221, "author": "Pete", "author_id": 13472, "author_profile": "https://Stackoverflow.com/users/13472", "pm_score": 3, "selected": false, "text": "for (Iterator<String> i = someList.iterator(); i.hasNext(); )\n System.out.println(i.next());\n" }, { "answer_id": 85232, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "for (Iterator<String> itr = someList.iterator(); itr.hasNext(); ) {\n String item = itr.next();\n System.out.println(item);\n}\n" }, { "answer_id": 85424, "author": "Mikezx6r", "author_id": 5382, "author_profile": "https://Stackoverflow.com/users/5382", "pm_score": 9, "selected": false, "text": "String[] fruits = new String[] { \"Orange\", \"Apple\", \"Pear\", \"Strawberry\" };\n\nfor (String fruit : fruits) {\n // fruit is an element of the `fruits` array.\n}\n" }, { "answer_id": 85933, "author": "Ryan Delucchi", "author_id": 9931, "author_profile": "https://Stackoverflow.com/users/9931", "pm_score": 5, "selected": false, "text": "T[]" }, { "answer_id": 7956673, "author": "MRocklin", "author_id": 616616, "author_profile": "https://Stackoverflow.com/users/616616", "pm_score": 7, "selected": false, "text": "char[] grades = ....\nfor(int i = 0; i < grades.length; i++) { // for i goes from 0 to grades.length\n System.out.print(grades[i]); // Print grades[i]\n}\n" }, { "answer_id": 12722557, "author": "oneConsciousness", "author_id": 1503768, "author_profile": "https://Stackoverflow.com/users/1503768", "pm_score": 4, "selected": false, "text": "// In this loop it is assumed that the list starts with index 0\nfor(int i=0; i<list.length; i++){\n\n}\n" }, { "answer_id": 19828685, "author": "PrivateName", "author_id": 2923930, "author_profile": "https://Stackoverflow.com/users/2923930", "pm_score": 5, "selected": false, "text": "for (type obj:array) {...}\n" }, { "answer_id": 22114571, "author": "aliteralmind", "author_id": 2736496, "author_profile": "https://Stackoverflow.com/users/2736496", "pm_score": 8, "selected": false, "text": "java.util.Iterator" }, { "answer_id": 23171818, "author": "Jrovalle", "author_id": 3551958, "author_profile": "https://Stackoverflow.com/users/3551958", "pm_score": 5, "selected": false, "text": "List<String> messages = Arrays.asList(\"First\", \"Second\", \"Third\");\n\nvoid forTest(){\n messages.forEach(System.out::println);\n}\n" }, { "answer_id": 32857986, "author": "Manohar", "author_id": 2039852, "author_profile": "https://Stackoverflow.com/users/2039852", "pm_score": 3, "selected": false, "text": "for" }, { "answer_id": 33232565, "author": "akhil_mittal", "author_id": 1216775, "author_profile": "https://Stackoverflow.com/users/1216775", "pm_score": 6, "selected": false, "text": "Iterable" }, { "answer_id": 40283536, "author": "Santhosh Rajkumar", "author_id": 6037775, "author_profile": "https://Stackoverflow.com/users/6037775", "pm_score": 3, "selected": false, "text": "public static Boolean Add_Tag(int totalsize)\n{\n List<String> fullst = new ArrayList<String>();\n for(int k=0; k<totalsize; k++)\n {\n fullst.addAll();\n }\n}\n" }, { "answer_id": 40857220, "author": "L Joey", "author_id": 5332814, "author_profile": "https://Stackoverflow.com/users/5332814", "pm_score": 3, "selected": false, "text": "Iterable interface" }, { "answer_id": 44018004, "author": "Alexander Drobyshevsky", "author_id": 1693748, "author_profile": "https://Stackoverflow.com/users/1693748", "pm_score": 4, "selected": false, "text": "List<String> someList = new ArrayList<String>();\n" }, { "answer_id": 48497277, "author": "Rei Brown", "author_id": 8352967, "author_profile": "https://Stackoverflow.com/users/8352967", "pm_score": 1, "selected": false, "text": "List<String> someList = new ArrayList<>(); //has content\nsomeList.forEach(System.out::println);\n" }, { "answer_id": 49015283, "author": "stackFan", "author_id": 3315482, "author_profile": "https://Stackoverflow.com/users/3315482", "pm_score": 3, "selected": false, "text": "Iterator<String> iterator = someList.iterator();\n\nwhile (iterator.hasNext()) {\n String item = iterator.next();\n System.out.println(item);\n}\n" }, { "answer_id": 50135519, "author": "gomisha", "author_id": 5719544, "author_profile": "https://Stackoverflow.com/users/5719544", "pm_score": 3, "selected": false, "text": "int [] intArray = {1, 3, 5, 7, 9};\nfor(int currentValue : intArray) {\n System.out.println(currentValue);\n}\n" }, { "answer_id": 50966962, "author": "Du-Lacoste", "author_id": 3600553, "author_profile": "https://Stackoverflow.com/users/3600553", "pm_score": 4, "selected": false, "text": "foreach" }, { "answer_id": 52098209, "author": "vivekkurien", "author_id": 3356847, "author_profile": "https://Stackoverflow.com/users/3356847", "pm_score": 4, "selected": false, "text": "List<String> someList = new ArrayList<String>();\nsomeList.add(\"A\");\nsomeList.add(\"B\");\nsomeList.add(\"C\");\n\nsomeList.forEach(listItem -> System.out.println(listItem))\n" }, { "answer_id": 59667941, "author": "mightyWOZ", "author_id": 4413098, "author_profile": "https://Stackoverflow.com/users/4413098", "pm_score": 3, "selected": false, "text": "-XD-printflat" }, { "answer_id": 65906872, "author": "nabayram", "author_id": 14692626, "author_profile": "https://Stackoverflow.com/users/14692626", "pm_score": 1, "selected": false, "text": "for (Iterator<String> i = someList.iterator(); i.hasNext(); ) {\n String x = i.next();\n System.out.println(x);\n}\n" }, { "answer_id": 66815146, "author": "Java-Dev", "author_id": 10428563, "author_profile": "https://Stackoverflow.com/users/10428563", "pm_score": 1, "selected": false, "text": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class ForLoopDemo {\n\n public static void main(String[] args) {\n\n List<String> someList = new ArrayList<String>();\n\n someList.add(\"monkey\");\n someList.add(\"donkey\");\n someList.add(\"skeleton key\");\n\n // Iteration using For Each loop\n System.out.println(\"Iteration using a For Each loop:\");\n for (String item : someList) {\n System.out.println(item);\n }\n\n // Iteration using a normal For loop\n System.out.println(\"\\nIteration using normal For loop: \");\n for (int index = 0; index < someList.size(); index++) {\n System.out.println(someList.get(index));\n }\n }\n}\n" }, { "answer_id": 71194990, "author": "IsraelCena", "author_id": 9877306, "author_profile": "https://Stackoverflow.com/users/9877306", "pm_score": 0, "selected": false, "text": "int[] numbers = {1,2,3,4,5};\n\nArrays.stream(numbers).forEach(System.out::println);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5074/" ]
85,223
<p>Of course most languages have library functions for this, but suppose I want to do it myself.</p> <p>Suppose that the float is given like in a C or Java program (except for the 'f' or 'd' suffix), for example "<code>4.2e1</code>", "<code>.42e2</code>" or simply "<code>42</code>". In general, we have the "integer part" before the decimal point, the "fractional part" after the decimal point, and the "exponent". All three are integers.</p> <p><strong>It is easy to find and process the individual digits, but how do you compose them into a value of type <code>float</code> or <code>double</code> without losing precision?</strong></p> <p>I'm thinking of multiplying the integer part with 10^<em>n</em>, where <em>n</em> is the number of digits in the fractional part, and then adding the fractional part to the integer part and subtracting <em>n</em> from the exponent. This effectively turns <code>4.2e1</code> into <code>42e0</code>, for example. Then I could use the <code>pow</code> function to compute 10^<em>exponent</em> and multiply the result with the new integer part. The question is, does this method guarantee maximum precision throughout?</p> <p>Any thoughts on this?</p>
[ { "answer_id": 85526, "author": "user7116", "author_id": 7116, "author_profile": "https://Stackoverflow.com/users/7116", "pm_score": 5, "selected": false, "text": "/* use this to start your atof implementation */\n\n/* atoi - christopher.watford@gmail.com */\n/* PUBLIC DOMAIN */\nlong atoi(const char *value) {\n unsigned long ival = 0, c, n = 1, i = 0, oval;\n for( ; c = value[i]; ++i) /* chomp leading spaces */\n if(!isspace(c)) break;\n if(c == '-' || c == '+') { /* chomp sign */\n n = (c != '-' ? n : -1);\n i++;\n }\n while(c = value[i++]) { /* parse number */\n if(!isdigit(c)) return 0;\n ival = (ival * 10) + (c - '0'); /* mult/accum */\n if((n > 0 && ival > LONG_MAX)\n || (n < 0 && ival > (LONG_MAX + 1UL))) {\n /* report overflow/underflow */\n errno = ERANGE;\n return (n > 0 ? LONG_MAX : LONG_MIN);\n }\n }\n return (n>0 ? (long)ival : -(long)ival);\n}\n" }, { "answer_id": 11253898, "author": "J D", "author_id": 13924, "author_profile": "https://Stackoverflow.com/users/13924", "pm_score": 1, "selected": false, "text": "int64" }, { "answer_id": 11705617, "author": "aka.nice", "author_id": 1396822, "author_profile": "https://Stackoverflow.com/users/1396822", "pm_score": 2, "selected": false, "text": "if(biasedExponent >= 0)\n return integerMantissa * (10^biasedExponent);\nelse\n return integerMantissa / (10^(-biasedExponent));\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14637/" ]
85,272
<p>Anyone can read the GoF book to learn what design patterns are and how to use them, but what is the process for figuring out when a design pattern solves a problem? Does the knowledge of the pattern drive the design, or is there a way to figure out how a pattern can be used to change a design?</p> <p>In other words, are there patterns for Patterns?</p>
[ { "answer_id": 279828, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 4, "selected": false, "text": "TYPE_t ary[SIZE] = // ... gets initialized somehow\nsize_t ix ; // Your index variable\n\nfor(ix=0; ix < SIZE; ix++){\n if (ary[ix] == item) {\n return ix ;\n }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7565/" ]
85,275
<p>I'm working on a game where I create a random map of provinces (a la Risk or Diplomacy). To create that map, I'm first generating a series of semi-random points, then figuring the Delaunay triangulations of those points. </p> <p>With that done, I am now looking to create a Voronoi diagram of the points to serve as a starting point for the province borders. My data at this point (no pun intended) consists of the original series of points and a collection of the Delaunay triangles.</p> <p>I've seen a number of ways to do this on the web, but most of them are tied up with how the Delaunay was derived. I'd love to find something that doesn't need to be integrated to the Delaunay, but can work based off the data alone. Failing that, I'm looking for something comprehensible to a relative geometry newbie, as opposed to optimal speed. Thanks!</p>
[ { "answer_id": 85484, "author": "Alexandra Franks", "author_id": 16203, "author_profile": "https://Stackoverflow.com/users/16203", "pm_score": 3, "selected": false, "text": "for yloop = 0 to height-1\n for xloop = 0 to width-1\n\n // Generate maximal value\n closest_distance = width * height\n\n for point = 0 to number_of_points-1\n // calls function to calc distance\n point_distance = distance(point, xloop, yloop)\n\n if point_distance < closest_distance\n closest_point = point\n end if\n next\n\n // place result in array of point types\n points[xloop, yloop] = point\n\n next\nnext\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8365/" ]
85,282
<p>In C# you can make a block inside of a method that is not attached to any other statement.</p> <pre><code> public void TestMethod() { { string x = "test"; string y = x; { int z = 42; int zz = z; } } } </code></pre> <p>This code compiles and runs just as if the braces inside the main method weren't there. Also notice the block inside of a block.</p> <p>Is there a scenario where this would be valuable? I haven't found any yet, but am curious to hear of other people's findings.</p>
[ { "answer_id": 85323, "author": "Anthony", "author_id": 5599, "author_profile": "https://Stackoverflow.com/users/5599", "pm_score": 2, "selected": false, "text": "if (someCondition)\n SimpleStatement();\n\nif (SomeCondition)\n{\n BlockOfStatements();\n}\n" }, { "answer_id": 85433, "author": "Tim Erickson", "author_id": 8787, "author_profile": "https://Stackoverflow.com/users/8787", "pm_score": 0, "selected": false, "text": "public void TestMethod()\n{\n //do something with some strings\n string x = \"test\";\n string y = x;\n\n //do something else with some ints\n int z = 42;\n int zz = z;\n}\n" }, { "answer_id": 86275, "author": "BlackTigerX", "author_id": 8411, "author_profile": "https://Stackoverflow.com/users/8411", "pm_score": 2, "selected": false, "text": " int a = 10;\n Console.WriteLine(a);\n\n int a = 20;\n Console.WriteLine(a);\n" }, { "answer_id": 86351, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 1, "selected": false, "text": "switch( value )\n{\n case const1: \n int i = GetValueSomeHow();\n //do something\n return i.ToString();\n\n case const2:\n int i = GetADifferentValue();\n //this will throw an exception - i is already declared\n ...\n" }, { "answer_id": 13864283, "author": "Servy", "author_id": 1159478, "author_profile": "https://Stackoverflow.com/users/1159478", "pm_score": 1, "selected": false, "text": "if" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3289/" ]
85,283
<p>I'm writting a financial C# application which receive messages from the network, translate them into different object according to the message type and finaly apply the application business logic on them.</p> <p>The point is that after the business logic is applied, I'm very sure I will never need this instance again. Rather than to wait for the garbage collector to free them, I'd like to explicitly "delete" them.</p> <p>Is there a better way to do so in C#, should I use a pool of object to reuse always the same set of instance or is there a better strategy.</p> <p>The goal being to avoid the garbage collection to use any CPU during a time critical process.</p>
[ { "answer_id": 87982, "author": "Eddie Velasquez", "author_id": 12851, "author_profile": "https://Stackoverflow.com/users/12851", "pm_score": 2, "selected": false, "text": "public class MyClass: IDisposable\n{\n private bool _disposed;\n\n public void Dispose()\n {\n Dispose( true );\n GC.SuppressFinalize( this );\n }\n\n protected virtual void Dispose( bool disposing )\n {\n if( _disposed ) \n return;\n\n if( disposing )\n {\n // Dispose managed resources here\n }\n\n _disposed = true;\n }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8315/" ]
85,353
<p>What is the best (or as good as possible) general SVN ignore pattern to use? </p> <p>There are a number of different IDE, editor, compiler, plug-in, platform, etc. specific files and some file types that "overlap" (i.e. desirable for some types projects and not for others). </p> <p><strong>There are however, a large number of file types that you just never want included in source control automatically regardless the specifics of your development environment.</strong></p> <p>The answer to this question would serve as a good starting point for any project - only requiring them to add the few environment specific items they need. It could be adapted for other Version Control Systems (VCS) as well.</p>
[ { "answer_id": 85371, "author": "icelava", "author_id": 2663, "author_profile": "https://Stackoverflow.com/users/2663", "pm_score": 3, "selected": false, "text": "*/bin */obj *.user *.suo\n" }, { "answer_id": 85440, "author": "noah", "author_id": 12034, "author_profile": "https://Stackoverflow.com/users/12034", "pm_score": 1, "selected": false, "text": "bin\n.*\n" }, { "answer_id": 843183, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": false, "text": "*.o *.lo .la ## .*.rej .rej .~ ~ .# .DS_Store thumbs.db Thumbs.db *.bak *.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk .msi .res *.pch *.suo *.exp ~. cvs CVS .CVS .cvs release Release debug Debug ignore Ignore bin Bin obj Obj *.csproj.user *.user _ReSharper.* *.resharper.user\n" }, { "answer_id": 6902355, "author": "Dalmas", "author_id": 533552, "author_profile": "https://Stackoverflow.com/users/533552", "pm_score": 1, "selected": false, "text": "ipch" }, { "answer_id": 7764856, "author": "Richard Dingwall", "author_id": 91551, "author_profile": "https://Stackoverflow.com/users/91551", "pm_score": 0, "selected": false, "text": "*.crunchsolution.* *.crunchproject.*\n" }, { "answer_id": 17672499, "author": "Holger Bille", "author_id": 1967424, "author_profile": "https://Stackoverflow.com/users/1967424", "pm_score": 0, "selected": false, "text": "*.stackdump core.*\n" }, { "answer_id": 39466037, "author": "koppor", "author_id": 873282, "author_profile": "https://Stackoverflow.com/users/873282", "pm_score": 0, "selected": false, "text": "# Created by https://www.gitignore.io/api/microsoftoffice,windows\n\n### MicrosoftOffice ###\n*.tmp\n\n# Word temporary\n~$*.doc*\n\n# Excel temporary\n~$*.xls*\n\n# Excel Backup File\n*.xlk\n\n# PowerPoint temporary\n~$*.ppt*\n\n# Visio autosave temporary files\n*.~vsdx\n\n\n### Windows ###\n# Windows image file caches\nThumbs.db\nehthumbs.db\n\n# Folder config file\nDesktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n" }, { "answer_id": 39466162, "author": "koppor", "author_id": 873282, "author_profile": "https://Stackoverflow.com/users/873282", "pm_score": 0, "selected": false, "text": "# Created by https://www.gitignore.io/api/microsoftoffice,windows\n\n### MicrosoftOffice ###\n*.tmp\n\n# Word temporary\n~$*.doc*\n\n# Excel temporary\n~$*.xls*\n\n# Excel Backup File\n*.xlk\n\n# PowerPoint temporary\n~$*.ppt*\n\n# Visio autosave temporary files\n*.~vsdx\n\n\n### Windows ###\n# Windows image file caches\nThumbs.db\nehthumbs.db\n\n# Folder config file\nDesktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2233/" ]
85,370
<p>My strongest lead is that the code who deals with the incoming XMLs is actually receiving an invalid/incomplete file hence failing the DOM parsing. Any suggestions?</p>
[ { "answer_id": 85448, "author": "Hank", "author_id": 7610, "author_profile": "https://Stackoverflow.com/users/7610", "pm_score": 2, "selected": false, "text": "doc.selectSingleNode(\"//some/element/in/a/structure\");\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6992/" ]
85,373
<p>In SQL Server, how do I "floor" a DATETIME to the second/minute/hour/day/year?</p> <p>Let's say that I have a date of <strong>2008-09-17 12:56:53.430</strong>, then the output of flooring should be:</p> <ul> <li>Year: 2008-01-01 00:00:00.000</li> <li>Month: 2008-09-01 00:00:00.000</li> <li>Day: 2008-09-17 00:00:00.000</li> <li>Hour: 2008-09-17 12:00:00.000</li> <li>Minute: 2008-09-17 12:56:00.000</li> <li>Second: 2008-09-17 12:56:53.000</li> </ul>
[ { "answer_id": 85379, "author": "Portman", "author_id": 1690, "author_profile": "https://Stackoverflow.com/users/1690", "pm_score": 8, "selected": true, "text": "declare @datetime datetime;\nset @datetime = getdate();\nselect @datetime;\nselect dateadd(year,datediff(year,0,@datetime),0);\nselect dateadd(month,datediff(month,0,@datetime),0);\nselect dateadd(day,datediff(day,0,@datetime),0);\nselect dateadd(hour,datediff(hour,0,@datetime),0);\nselect dateadd(minute,datediff(minute,0,@datetime),0);\nselect dateadd(second,datediff(second,'2000-01-01',@datetime),'2000-01-01');\nselect dateadd(week,datediff(week,0,@datetime),-1); --Beginning of week is Sunday\nselect dateadd(week,datediff(week,0,@datetime),0); --Beginning of week is Monday\n" }, { "answer_id": 86499, "author": "Chris Wuestefeld", "author_id": 10082, "author_profile": "https://Stackoverflow.com/users/10082", "pm_score": 5, "selected": false, "text": "SELECT CAST(FLOOR(CAST(CURRENT_TIMESTAMP AS float)) AS DATETIME)\n" }, { "answer_id": 561614, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "date_trunc()\n" }, { "answer_id": 10212540, "author": "Moe Cazzell", "author_id": 1341767, "author_profile": "https://Stackoverflow.com/users/1341767", "pm_score": 4, "selected": false, "text": "cast(cast(getdate() as date) as datetime)\n" }, { "answer_id": 17860749, "author": "Dan Atkinson", "author_id": 31532, "author_profile": "https://Stackoverflow.com/users/31532", "pm_score": 3, "selected": false, "text": "IF OBJECT_ID('fn_FloorDate') IS NOT NULL DROP FUNCTION fn_FloorDate\nSET ANSI_NULLS OFF\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nCREATE FUNCTION [dbo].[fn_FloorDate] (\n @Date DATETIME = NULL,\n @DatePart VARCHAR(6) = 'day'\n)\nRETURNS DATETIME\nAS\nBEGIN\n IF (@Date IS NULL)\n SET @Date = GETDATE();\n\n RETURN\n CASE\n WHEN LOWER(@DatePart) = 'year' THEN DATEADD(YEAR, DATEDIFF(YEAR, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'month' THEN DATEADD(MONTH, DATEDIFF(MONTH, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'day' THEN DATEADD(DAY, DATEDIFF(DAY, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'hour' THEN DATEADD(HOUR, DATEDIFF(HOUR, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'minute' THEN DATEADD(MINUTE, DATEDIFF(MINUTE, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'second' THEN DATEADD(SECOND, DATEDIFF(SECOND, '2000-01-01', @Date), '2000-01-01')\n ELSE DATEADD(DAY, DATEDIFF(DAY, 0, @Date), 0)\n END;\nEND\n" }, { "answer_id": 26166191, "author": "Sean", "author_id": 4103350, "author_profile": "https://Stackoverflow.com/users/4103350", "pm_score": 1, "selected": false, "text": "select convert(datetime,convert(varchar,CURRENT_TIMESTAMP,101))\n" }, { "answer_id": 37059540, "author": "pinaldave", "author_id": 892707, "author_profile": "https://Stackoverflow.com/users/892707", "pm_score": 0, "selected": false, "text": "----Last Day of Previous Month\nSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))\nLastDay_PreviousMonth\n----Last Day of Current Month\nSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0))\nLastDay_CurrentMonth\n----Last Day of Next Month\nSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+2,0))\nLastDay_NextMonth\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1690/" ]
85,451
<p>Which is better to use for timing in Python? time.clock() or time.time()? Which one provides more accuracy?</p> <p>for example:</p> <pre><code>start = time.clock() ... do something elapsed = (time.clock() - start) </code></pre> <p>vs.</p> <pre><code>start = time.time() ... do something elapsed = (time.time() - start) </code></pre>
[ { "answer_id": 85489, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 4, "selected": false, "text": "clock()" }, { "answer_id": 85511, "author": "PierreBdR", "author_id": 7136, "author_profile": "https://Stackoverflow.com/users/7136", "pm_score": 6, "selected": false, "text": "time.clock()" }, { "answer_id": 85536, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 5, "selected": false, "text": "time.time()" }, { "answer_id": 2246226, "author": "Seba", "author_id": 271241, "author_profile": "https://Stackoverflow.com/users/271241", "pm_score": 4, "selected": false, "text": "time.time()" }, { "answer_id": 21178451, "author": "bestwolf1983", "author_id": 3205257, "author_profile": "https://Stackoverflow.com/users/3205257", "pm_score": 4, "selected": false, "text": "time()" }, { "answer_id": 21374146, "author": "Hill", "author_id": 3239341, "author_profile": "https://Stackoverflow.com/users/3239341", "pm_score": -1, "selected": false, "text": ">>> start = time.time(); time.sleep(0.5); (time.time() - start)\n0.5005500316619873\n" }, { "answer_id": 35929913, "author": "Nurul Akter Towhid", "author_id": 4294015, "author_profile": "https://Stackoverflow.com/users/4294015", "pm_score": 3, "selected": false, "text": "import time\n\ndef t_time():\n start=time.time()\n time.sleep(0.1)\n return (time.time()-start)\n\n\ndef t_clock():\n start=time.clock()\n time.sleep(0.1)\n return (time.clock()-start)\n\n\n\n\ncounter_time=0\ncounter_clock=0\n\nfor i in range(1,100):\n counter_time += t_time()\n\n for i in range(1,100):\n counter_clock += t_clock()\n\nprint \"time() =\",counter_time/100\nprint \"clock() =\",counter_clock/100\n" }, { "answer_id": 40677139, "author": "dsgdfg", "author_id": 2133240, "author_profile": "https://Stackoverflow.com/users/2133240", "pm_score": 1, "selected": false, "text": "subject" }, { "answer_id": 49667496, "author": "Chris_Rands", "author_id": 6260170, "author_profile": "https://Stackoverflow.com/users/6260170", "pm_score": 3, "selected": false, "text": "time.clock()" }, { "answer_id": 62115682, "author": "xjcl", "author_id": 2111778, "author_profile": "https://Stackoverflow.com/users/2111778", "pm_score": 2, "selected": false, "text": "time.clock()" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16148/" ]
85,457
<p>I am trying to inherit from my generated datacontext in LinqToSQL - something like this </p> <pre><code>public class myContext : dbDataContext { public System.Data.Linq.Table&lt;User&gt;() Users { return (from x in base.Users() where x.DeletedOn.HasValue == false select x); } } </code></pre> <p>But my Linq statement returns IQueryable which cannot cast to Table - does anyone know a way to limit the contents of a Linq.Table - I am trying to be certain that anywhere my Users table is accessed, it doesn't return those marked deleted. Perhaps I am going about this all wrong - any suggestions would be greatly appreciated.</p> <p>Hal</p>
[ { "answer_id": 85507, "author": "Scott Nichols", "author_id": 4299, "author_profile": "https://Stackoverflow.com/users/4299", "pm_score": 1, "selected": false, "text": "Users.OfType<ActiveUsers>\n" }, { "answer_id": 85989, "author": "Scott Nichols", "author_id": 4299, "author_profile": "https://Stackoverflow.com/users/4299", "pm_score": 3, "selected": true, "text": "CREATE VIEW ActiveUsers as SELECT * FROM Users WHERE IsDeleted = 0\n" }, { "answer_id": 89144, "author": "liammclennan", "author_id": 2785, "author_profile": "https://Stackoverflow.com/users/2785", "pm_score": 1, "selected": false, "text": "from item in All\nwhere ...\nselect item\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16416/" ]
85,459
<p>I have a series of PDFs named sequentially like so:</p> <ul> <li>01_foo.pdf</li> <li>02_bar.pdf</li> <li>03_baz.pdf</li> <li>etc.</li> </ul> <p>Using Ruby, is it possible to combine these into one big PDF while keeping them in sequence? I don't mind installing any necessary gems to do the job.</p> <p>If this isn't possible in Ruby, how about another language? No commercial components, if possible.</p> <hr> <p><strong>Update:</strong> <a href="https://stackoverflow.com/questions/85459/is-it-possible-to-combine-a-series-of-pdfs-into-one-using-ruby#85618">Jason Navarrete's suggestion</a> lead to the perfect solution:</p> <p>Place the PDF files needing to be combined in a directory along with <a href="http://www.accesspdf.com/pdftk/" rel="nofollow noreferrer">pdftk</a> (or make sure pdftk is in your PATH), then run the following script:</p> <pre><code>pdfs = Dir["[0-9][0-9]_*"].sort.join(" ") `pdftk #{pdfs} output combined.pdf` </code></pre> <p>Or I could even do it as a one-liner from the command-line:</p> <pre><code>ruby -e '`pdftk #{Dir["[0-9][0-9]_*"].sort.join(" ")} output combined.pdf`' </code></pre> <p>Great suggestion Jason, perfect solution, thanks. <strong>Give him an up-vote people</strong>.</p>
[ { "answer_id": 85576, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": false, "text": "system()" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1944/" ]
85,479
<p>Can someone give an example of a good time to actually use "unsafe" and "fixed" in C# code? I've played with it before, but never actually found a good use for it. </p> <p>Consider this code...</p> <pre><code>fixed (byte* pSrc = src, pDst = dst) { //Code that copies the bytes in a loop } </code></pre> <p>compared to simply using...</p> <pre><code>Array.Copy(source, target, source.Length); </code></pre> <p>The second is the code found in the .NET Framework, the first a part of the code copied from the Microsoft website, <a href="http://msdn.microsoft.com/en-us/library/28k1s2k6(VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/28k1s2k6(VS.80).aspx</a>.</p> <p>The built in Array.Copy() is dramatically faster than using Unsafe code. This might just because the second is just better written and the first is just an example, but what kinds of situations would you really even need to use Unsafe/Fixed code for anything? Or is this poor web developer messing with something above his head?</p>
[ { "answer_id": 85774, "author": "Rune", "author_id": 7948, "author_profile": "https://Stackoverflow.com/users/7948", "pm_score": 5, "selected": false, "text": "unsafe\n{\n BitmapData bmData = bm.LockBits(...)\n byte *bits = (byte*)pixels.ToPointer();\n // Do stuff with bits\n}\n" }, { "answer_id": 488202, "author": "ShuggyCoUk", "author_id": 12748, "author_profile": "https://Stackoverflow.com/users/12748", "pm_score": 3, "selected": false, "text": "public static unsafe int UInt32ToInt32Bits(uint x)\n{\n return *((int*)(void*)&x);\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
85,481
<p>Say I've got this table (SQL Server 2005):</p> <pre><code>Id =&gt; integer MyField =&gt; XML </code></pre> <p><b>Id MyField</b> </p> <pre><code>1 &lt; Object&gt;&lt; Type&gt;AAA&lt; /Type&gt;&lt; Value&gt;10&lt; /Value&gt;&lt; /Object&gt;&lt; Object&gt;&lt; Type&gt;BBB&lt; /Type&gt;&lt;Value&gt;20&lt; /Value&gt;&lt; /Object&gt; 2 &lt; Object&gt;&lt; Type&gt;AAA&lt; /Type&gt;&lt; Value&gt;15&lt; /Value&gt;&lt; /Object&gt; 3 &lt; Object&gt;&lt; Type&gt;AAA&lt; /Type&gt;&lt; Value&gt;20&lt; /Value&gt;&lt; /Object&gt;&lt; Object&gt;&lt; Type&gt;BBB&lt; /Type&gt;&lt; Value&gt;30&lt; /Value&gt;&lt; /Object&gt; </code></pre> <p>I need a TSQL query which would return something like this:</p> <pre><code>Id AAA BBB 1 10 20 2 15 NULL 3 20 30 </code></pre> <p>Note that I won't know if advance how many <code>'Type'</code> (eg AAA, BBB, CCC,DDD, etc.) there will be in the xml string.</p>
[ { "answer_id": 85535, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 1, "selected": false, "text": "select id, MyField.query('/Object/Type[.=\"AAA\"]/Value') as AAA, MyField.query('/Object/Type[.=\"BBB\"]/Value) AS BBB\n" }, { "answer_id": 182780, "author": "Josef", "author_id": 5581, "author_profile": "https://Stackoverflow.com/users/5581", "pm_score": 0, "selected": false, "text": "CROSS APPLY" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15928/" ]
85,486
<p>I'm trying to add an SVN repository to Eclipse. </p> <p>I've installed <a href="http://subclipse.tigris.org/" rel="noreferrer">Subclipse</a>, and it seems to be working fine. But, when I try to "add a new SVN repository", I input this, for example:</p> <p><em><a href="http://svn.python.org/projects/peps/trunk" rel="noreferrer">http://svn.python.org/projects/peps/trunk</a></em></p> <p>I get this:</p> <blockquote> <p>Error validating location: "org.tigris.subversion.javahl.ClientException: RA layer request failed svn: OPTIONS of '<a href="http://svn.python.org/projects/peps/trunk" rel="noreferrer">http://svn.python.org/projects/peps/trunk</a>': could not connect to server (<a href="http://svn.python.org" rel="noreferrer">http://svn.python.org</a>) " Keep location anyway?</p> </blockquote> <p>I know that my Eclipse can connect to the Internet, because I downloaded Subclipse earlier (I had to change my proxy settings). </p> <p>I get a similar message for other SVN locations I've tried to add. </p> <p>What is the solution?</p>
[ { "answer_id": 85619, "author": "bengineerd", "author_id": 10428, "author_profile": "https://Stackoverflow.com/users/10428", "pm_score": 2, "selected": false, "text": "$ svn checkout http://svn.python.org/projects/peps/trunk\n" }, { "answer_id": 85852, "author": "Mike Tunnicliffe", "author_id": 13956, "author_profile": "https://Stackoverflow.com/users/13956", "pm_score": 1, "selected": false, "text": "Subclipse 1.4.0\nSubversion Client Adapter 1.5.0.1\nSVNKit Client Adapter 1.5.0.1\nSVNKit Library 1.2.0.4502\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1179/" ]
85,487
<p>How do I perform a reverse DNS lookup, that is how do I resolve an IP address to its DNS hostname in Perl?</p>
[ { "answer_id": 85573, "author": "Joakim", "author_id": 16432, "author_profile": "https://Stackoverflow.com/users/16432", "pm_score": 4, "selected": false, "text": "use Socket;\n$iaddr = inet_aton(\"127.0.0.1\"); # or whatever address\n$name = gethostbyaddr($iaddr, AF_INET);\n" }, { "answer_id": 85640, "author": "Jeff", "author_id": 10157, "author_profile": "https://Stackoverflow.com/users/10157", "pm_score": 5, "selected": false, "text": "use Net::DNS;\nmy $res = Net::DNS::Resolver->new;\n\n# create the reverse lookup DNS name (note that the octets in the IP address need to be reversed).\nmy $IP = \"209.85.173.103\";\nmy $target_IP = join('.', reverse split(/\\./, $IP)).\".in-addr.arpa\";\n\nmy $query = $res->query(\"$target_IP\", \"PTR\");\n\nif ($query) {\n foreach my $rr ($query->answer) {\n next unless $rr->type eq \"PTR\";\n print $rr->rdatastr, \"\\n\";\n }\n} else {\n warn \"query failed: \", $res->errorstring, \"\\n\";\n}\n" }, { "answer_id": 97636, "author": "Jagmal", "author_id": 4406, "author_profile": "https://Stackoverflow.com/users/4406", "pm_score": 0, "selected": false, "text": "$ip = \"XXX.XXX.XXX.XXX\" # IPV4 address.\nmy @numbers = split (/\\./, $ip);\nif (scalar(@numbers) != 4)\n{\n print \"$ip is not a valid IP address.\\n\";\n next;\n}\nmy $ip_addr = pack(\"C4\", @numbers);\n# First element of the array returned by gethostbyaddr is host name.\nmy ($name) = (gethostbyaddr($ip_addr, 2))[0];\n" }, { "answer_id": 1373424, "author": "Kai Carver", "author_id": 153144, "author_profile": "https://Stackoverflow.com/users/153144", "pm_score": 2, "selected": false, "text": "perl -MSocket -E 'say scalar gethostbyaddr(inet_aton(\"79.81.152.79\"), AF_INET)'\n" }, { "answer_id": 12810035, "author": "John Boone", "author_id": 1733284, "author_profile": "https://Stackoverflow.com/users/1733284", "pm_score": 2, "selected": false, "text": "perl -MSocket -E 'say scalar gethostbyaddr(inet_aton(\"69.89.27.250\"), AF_INET)'\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16432/" ]
85,500
<p>First time working with UpdatePanels in .NET. </p> <p>I have an updatepanel with a trigger pointed to an event on a FormView control. The UpdatePanel holds a ListView with related data from a separate database.</p> <p>When the UpdatePanel refreshes, it needs values from the FormView control so that on the server it can use them to query the database.</p> <p>For the life if me, I can't figure out how to get those values. The event I'm triggering from has them, but I want the updatepanel to refresh asynchronously. How do I pass values to the load event on the panel?</p> <p>Googled this ad nauseum and can't seem to get to an answer here. A link or an explanation would be immensely helpful..</p> <p>Jeff</p>
[ { "answer_id": 86520, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 3, "selected": true, "text": "<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n<head runat=\"server\">\n <title>Untitled Page</title>\n <script type=\"text/javascript\" src=\"AjaxHelper.js\"></script>\n</head>\n<body>\n <form id=\"form1\" runat=\"server\">\n <div>\n <asp:TextBox ID=\"txtSearchValue\" runat=\"server\"></asp:TextBox>\n <input id=\"btnSearch\" type=\"button\" value=\"Search by partial full name\" onclick=\"doSearch()\"/>\n\n <igtbl:ultrawebgrid id=\"uwgUsers\" runat=\"server\" \n//infragistics grid crap\n </igtbl:ultrawebgrid>--%>\n </div>\n </form>\n</body>\n</html>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16426/" ]
85,553
<p>MSDN says that you should use structs when you need lightweight objects. Are there any other scenarios when a struct is preferable over a class?</p> <p>Some people might have forgotten that:</p> <ol> <li><em>structs</em> can have methods.</li> <li><em>structs</em> cannot be inherited.</li> </ol> <p>I understand the technical differences between structs and classes, I just don't have a good feel for <strong>when</strong> to use a struct.</p>
[ { "answer_id": 470416, "author": "Andrei Rînea", "author_id": 1796, "author_profile": "https://Stackoverflow.com/users/1796", "pm_score": 6, "selected": false, "text": "public struct ThreeDimensionalPoint\n{\n public readonly int X, Y, Z;\n public ThreeDimensionalPoint(int x, int y, int z)\n {\n this.X = x;\n this.Y = y;\n this.Z = z;\n }\n\n public override string ToString()\n {\n return \"(X=\" + this.X + \", Y=\" + this.Y + \", Z=\" + this.Z + \")\";\n }\n\n public override int GetHashCode()\n {\n return (this.X + 2) ^ (this.Y + 2) ^ (this.Z + 2);\n }\n\n public override bool Equals(object obj)\n {\n if (!(obj is ThreeDimensionalPoint))\n return false;\n ThreeDimensionalPoint other = (ThreeDimensionalPoint)obj;\n return this == other;\n }\n\n public static bool operator ==(ThreeDimensionalPoint p1, ThreeDimensionalPoint p2)\n {\n return p1.X == p2.X && p1.Y == p2.Y && p1.Z == p2.Z;\n }\n\n public static bool operator !=(ThreeDimensionalPoint p1, ThreeDimensionalPoint p2)\n {\n return !(p1 == p2);\n }\n}\n" }, { "answer_id": 60475290, "author": "Eduardas Šlutas", "author_id": 7838447, "author_profile": "https://Stackoverflow.com/users/7838447", "pm_score": 3, "selected": false, "text": "public class TestClass\n{\n public long ID { get; set; }\n public string FirstName { get; set; }\n public string LastName { get; set; }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
85,559
<p>I have a problem in my project with the .designer which as everyone know is autogenerated and I ahvent changed at all. One day I was working fine, I did a back up and next day boom! the project suddenly stops working and sends a message that the designer cant procees a code line... and due to this I get more errores (2 in my case), I even had a back up from the day it was working and is useless too, I get the same error, I tryed in my laptop and the same problem comes. How can I delete the &quot;FitTrack&quot;? The incredible part is that while I was trying on the laptop the errors on the desktop were gone in front of my eyes, one and one second later the other one (but still have the warning from the designer and cant see the form), I closed and open it again and again I have the errors...</p> <p>The error is:</p> <pre><code>Warning 1 The designer cannot process the code at line 27: Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11 The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. C:\Documents and Settings\Alan Cardero\Desktop\Reportes Liquidacion\Reportes Liquidacion\Reportes Liquidacion\Form1.Designer.vb 28 0 </code></pre>
[ { "answer_id": 85602, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 1, "selected": false, "text": "If(Not DesignMode) Then Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
85,577
<p>I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?</p>
[ { "answer_id": 85632, "author": "Sylvain Defresne", "author_id": 5353, "author_profile": "https://Stackoverflow.com/users/5353", "pm_score": 1, "selected": false, "text": "arping" }, { "answer_id": 86541, "author": "akiva", "author_id": 65724, "author_profile": "https://Stackoverflow.com/users/65724", "pm_score": -1, "selected": false, "text": "ifconfig" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11760/" ]
85,622
<p>Most precompiled Windows binaries are made with the MSYS+gcc toolchain. It uses MSVCRT runtime, which is incompatible with Visual C++ 2005/2008.</p> <p>So, how to go about and compile Cairo 1.6.4 (or later) for Visual C++ only. Including dependencies (png,zlib,pixman).</p>
[ { "answer_id": 96168, "author": "jfs", "author_id": 6223, "author_profile": "https://Stackoverflow.com/users/6223", "pm_score": 0, "selected": false, "text": "config.h" }, { "answer_id": 6704146, "author": "Sergeq", "author_id": 846031, "author_profile": "https://Stackoverflow.com/users/846031", "pm_score": 1, "selected": false, "text": "sed \"s/^if \\([A-Z_]*\\)$/ifeq ($(\\1), 1)/\" src\\Makefile.sources\n" }, { "answer_id": 33718258, "author": "jingyu9575", "author_id": 1997315, "author_profile": "https://Stackoverflow.com/users/1997315", "pm_score": 2, "selected": false, "text": ". (my_cairo_build_root)\n├─cairo\n├─libpng\n├─pixman\n└─zlib\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14455/" ]
85,649
<p>How do I remove a USB drive using the Win32 API? I do a lot of work on embedded systems and on one of these I have to copy my programs on a USB stick and insert it into the target hardware.</p> <p>Since I mostly work on the console I don't like to use the mouse and click on the small task-bar icon hundred times a day. </p> <p>I'd love to write a little program to do exactly that so I can put it into my makefiles, but I haven't found any API call that does the same thing.</p> <p>Any ideas?</p>
[ { "answer_id": 85678, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 3, "selected": false, "text": "sync -e [drive_letter]" }, { "answer_id": 85694, "author": "Kris Kumler", "author_id": 4281, "author_profile": "https://Stackoverflow.com/users/4281", "pm_score": 5, "selected": true, "text": "CM_Request_Device_Eject()" }, { "answer_id": 85723, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 2, "selected": false, "text": "DismountNtmsMedia" }, { "answer_id": 64381851, "author": "VictorV", "author_id": 6119813, "author_profile": "https://Stackoverflow.com/users/6119813", "pm_score": 0, "selected": false, "text": "#include<SetupAPI.h>\n#include <windows.h> \n#include<initguid.h>\n#include <newdev.h>\n#include <Cfgmgr32.h>\n\n#pragma comment(lib, \"Cfgmgr32.lib\")\n#pragma comment(lib, \"Setupapi.lib\")\n#pragma comment(lib, \"Newdev.lib\")\n\nint RemoveDevice(const GUID *guid, const wchar_t *hwID) {\n HDEVINFO m_hDevInfo;\n SP_DEVICE_INTERFACE_DATA spdid;\n SP_DEVINFO_DATA spdd;\n DWORD dwSize;\n BYTE Buf[1024];\n PSP_DEVICE_INTERFACE_DETAIL_DATA pspdidd =\n (PSP_DEVICE_INTERFACE_DETAIL_DATA)Buf;\n\n printf(\"try to remove device::%ws\\n\", hwID);\n\n m_hDevInfo = SetupDiGetClassDevs(guid, NULL, NULL, DIGCF_PRESENT| DIGCF_DEVICEINTERFACE);\n if (m_hDevInfo == INVALID_HANDLE_VALUE)\n {\n printf(\"GetClassDevs Failed!\\n\");\n return 0;\n }\n spdid.cbSize = sizeof(spdid);\n for (int i = 0; SetupDiEnumDeviceInterfaces(m_hDevInfo, NULL, guid, i, &spdid); i++) {\n dwSize = 0;\n SetupDiGetDeviceInterfaceDetail(m_hDevInfo,\n &spdid, NULL, 0, &dwSize, NULL);\n if (dwSize != 0 && dwSize <= sizeof(Buf)) {\n pspdidd->cbSize = sizeof(*pspdidd); // 5 Bytes!\n\n ZeroMemory((PVOID)&spdd, sizeof(spdd));\n spdd.cbSize = sizeof(spdd);\n\n long res =\n SetupDiGetDeviceInterfaceDetail(m_hDevInfo, &\n spdid, pspdidd,\n dwSize, &dwSize,\n &spdd);\n if (res) {\n OLECHAR* guidString;\n OLECHAR* guidString2;\n StringFromCLSID(&spdd.ClassGuid, &guidString);\n StringFromCLSID(&spdid.InterfaceClassGuid, &guidString2);\n printf(\"%d, %ws, %ws, %ws\\n\", spdd.DevInst, pspdidd->DevicePath, guidString, guidString2);\n CoTaskMemFree(guidString);\n CoTaskMemFree(guidString2);\n if (!memcmp(pspdidd->DevicePath, hwID, 2 * lstrlenW(hwID))) {\n DEVINST DevInstParent = 0;\n res = CM_Get_Parent(&DevInstParent, spdd.DevInst, 0);\n for (long tries = 0; tries < 10; tries++) {\n // sometimes we need some tries...\n WCHAR VetoNameW[MAX_PATH];\n PNP_VETO_TYPE VetoType = PNP_VetoTypeUnknown;\n VetoNameW[0] = 0;\n\n res = CM_Request_Device_EjectW(DevInstParent,\n &VetoType, VetoNameW, MAX_PATH, 0);\n if ((res == CR_SUCCESS &&\n VetoType == PNP_VetoTypeUnknown)) {\n printf(\"remove %ws success!\\n\", pspdidd->DevicePath);\n SetupDiDestroyDeviceInfoList(m_hDevInfo);\n return 1;\n }\n Sleep(500); // required to give the next tries a chance!\n }\n break;\n }\n }\n }\n }\n printf(\"Remove Device Failed!\\n\");\n SetupDiDestroyDeviceInfoList(m_hDevInfo);\n return 0;\n}\n\nint main(){\n GUID GUID_DEVINTERFACE_USB_HUB;\n CLSIDFromString(L\"F18A0E88-C30C-11D0-8815-00A0C906BED8\", &GUID_DEVINTERFACE_USB_HUB);\n\n RemoveDevice(&GUID_DEVINTERFACE_USB_HUB, L\"\\\\\\\\?\\\\usb#root_hub30\");\n return 0;\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15955/" ]
85,675
<p>I have two tables I would like to complare. One of the columns is type CLOB. I would like to do something like this:</p> <pre><code>select key, clob_value source_table minus select key, clob_value target_table </code></pre> <p>Unfortunately, Oracle can't perform minus operations on clobs. How can I do this?</p>
[ { "answer_id": 85716, "author": "hamishmcn", "author_id": 3590, "author_profile": "https://Stackoverflow.com/users/3590", "pm_score": 2, "selected": false, "text": "select key, to_hash_str_val(glob_value) from source_table\nminus\nselect key, to_hash_str_val(glob_value) from target_table\n" }, { "answer_id": 85730, "author": "Nick Craver", "author_id": 13249, "author_profile": "https://Stackoverflow.com/users/13249", "pm_score": 5, "selected": true, "text": "dbms_lob.compare( \nlob_1 IN BLOB, \nlob_2 IN BLOB, \namount IN INTEGER := 18446744073709551615, \noffset_1 IN INTEGER := 1, \noffset_2 IN INTEGER := 1) \nRETURN INTEGER; \n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16484/" ]
85,699
<p>I'm building a group calendar application that needs to support recurring events, but all the solutions I've come up with to handle these events seem like a hack. I can limit how far ahead one can look, and then generate all the events at once. Or I can store the events as repeating and dynamically display them when one looks ahead on the calendar, but I'll have to convert them to a normal event if someone wants to change the details on a particular instance of the event.</p> <p>I'm sure there's a better way to do this, but I haven't found it yet. What's the best way to model recurring events, where you can change details of or delete particular event instances?</p> <p>(I'm using Ruby, but please don't let that constrain your answer. If there's a Ruby-specific library or something, though, that's good to know.)</p>
[ { "answer_id": 85909, "author": "Purfideas", "author_id": 4615, "author_profile": "https://Stackoverflow.com/users/4615", "pm_score": 2, "selected": false, "text": "#!/usr/bin/ruby\nrequire 'date'\n\nstart_date = Date.parse('2008-01-01')\nend_date = Date.parse('2008-04-01')\nwday = 5 # friday\n\n(start_date..end_date).select{|d| d.wday == wday}.map{|d| d.to_s}.inspect\n" }, { "answer_id": 4001814, "author": "Vee", "author_id": 459940, "author_profile": "https://Stackoverflow.com/users/459940", "pm_score": 4, "selected": false, "text": "form.schedule :as => :recurring" }, { "answer_id": 26770786, "author": "fozua", "author_id": 2753345, "author_profile": "https://Stackoverflow.com/users/2753345", "pm_score": 0, "selected": false, "text": "TableID: 1 Name: cycleA \nStartTime: 6 November 2014 (I kept thenumber of milliseconds), \nEndTime: 6 November 2015 (if it is repeated forever, and you can keep the value -1) \nCycletype: WeekLy.\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6262/" ]
85,701
<p>I have a database field that contains a raw date field (stored as character data), such as </p> <blockquote> <p>Friday, September 26, 2008 8:30 PM Eastern Daylight Time</p> </blockquote> <p>I can parse this as a Date easily, with SimpleDateFormat</p> <pre><code>DateFormat dbFormatter = new SimpleDateFormat("EEEE, MMMM dd, yyyy hh:mm aa zzzz"); Date scheduledDate = dbFormatter.parse(rawDate); </code></pre> <p>What I'd like to do is extract a TimeZone object from this string. The default TimeZone in the JVM that this application runs in is GMT, so I can't use <code>.getTimezoneOffset()</code> from the <code>Date</code> parsed above (because it will return the default TimeZone).</p> <p>Besides tokenizing the raw string and finding the start position of the Timezone string (since I know the format will always be <code>EEEE, MMMM dd, yyyy hh:mm aa zzzz</code>) is there a way using the DateFormat/SimpleDateFormat/Date/Calendar API to extract a TimeZone object - which will have the same TimeZone as the String I've parsed apart with <code>DateFormat.parse()</code>?</p> <p>One thing that bugs me about <code>Date</code> vs <code>Calendar</code> in the Java API is that <code>Calendar</code> is supposed to replace <code>Date</code> in all places... but then they decided, oh hey let's still use <code>Date</code>'s in the <code>DateFormat</code> classes.</p>
[ { "answer_id": 86183, "author": "Ed Thomas", "author_id": 8256, "author_profile": "https://Stackoverflow.com/users/8256", "pm_score": 2, "selected": false, "text": " DateFormat dbFormatter = new SimpleDateFormat(\"EEEE, MMMM dd, yyyy hh:mm aa zzzz\");\n dbFormatter.setTimeZone(TimeZone.getTimeZone(\"America/Chicago\"));\n Date scheduledDate = dbFormatter.parse(\"Friday, September 26, 2008 8:30 PM Eastern Daylight Time\");\n System.out.println(scheduledDate);\n System.out.println(dbFormatter.format(scheduledDate));\n TimeZone tz = dbFormatter.getTimeZone();\n System.out.println(tz.getDisplayName());\n dbFormatter.setTimeZone(TimeZone.getTimeZone(\"America/Chicago\"));\n System.out.println(dbFormatter.format(scheduledDate));\n" }, { "answer_id": 86229, "author": "Roland Schneider", "author_id": 16515, "author_profile": "https://Stackoverflow.com/users/16515", "pm_score": 0, "selected": false, "text": "import java.text.DateFormat;\nimport java.text.ParseException;\nimport java.text.SimpleDateFormat;\n\npublic class TimeZoneExtracter {\n\n public static final void main(String[] args) throws ParseException {\n DateFormat dbFormatter = new SimpleDateFormat(\"EEEE, MMMM dd, yyyy hh:mm aa zzzz\");\n System.out.println(dbFormatter.getTimeZone());\n dbFormatter.parse(\"Fr, September 26, 2008 8:30 PM Eastern Daylight Time\");\n System.out.println(dbFormatter.getTimeZone());\n }\n\n}\n" }, { "answer_id": 86303, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 1, "selected": false, "text": "String testString = \"Friday, September 26, 2008 8:30 PM Pacific Standard Time\";\nDateFormat df = new SimpleDateFormat(\"EEEE, MMMM dd, yyyy hh:mm aa zzzz\");\n\nSystem.out.println(\"The default TimeZone is: \" + TimeZone.getDefault().getDisplayName());\n\nSystem.out.println(\"DateFormat timezone before parse: \" + df.getTimeZone().getDisplayName());\n\nDate date = df.parse(testString);\n\nSystem.out.println(\"Parsed [\" + testString + \"] to Date: \" + date);\n\nSystem.out.println(\"DateFormat timezone after parse: \" + df.getTimeZone().getDisplayName());\n" }, { "answer_id": 86411, "author": "Mike Pone", "author_id": 16404, "author_profile": "https://Stackoverflow.com/users/16404", "pm_score": 0, "selected": false, "text": " String rawDate = \"Friday, September 26, 2008 8:30 PM Eastern Daylight Time\";\n DateFormat dbFormatter = new SimpleDateFormat(\"EEEE, MMMM dd, yyyy hh:mm aa zzzz\");\n Date scheduledDate = dbFormatter.parse(rawDate);\n\n System.out.println(rawDate); \n System.out.println(scheduledDate); \n System.out.println(dbFormatter.getTimeZone().getDisplayName());\n" }, { "answer_id": 40254182, "author": "Basil Bourque", "author_id": 642706, "author_profile": "https://Stackoverflow.com/users/642706", "pm_score": 1, "selected": false, "text": "ZonedDateTime.parse( \n \"Friday, September 26, 2008 8:30 PM Eastern Daylight Time\" , \n DateTimeFormatter.ofPattern( \"EEEE, MMMM d, uuuu h:m a zzzz\" ) \n).getZone()\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
85,702
<p>I want to have a "select-only" <code>ComboBox</code> that provides a list of items for the user to select from. Typing should be disabled in the text portion of the <code>ComboBox</code> control.</p> <p>My initial googling of this turned up an overly complex, misguided suggestion to capture the <code>KeyPress</code> event.</p>
[ { "answer_id": 85706, "author": "Cory Engebretson", "author_id": 3406, "author_profile": "https://Stackoverflow.com/users/3406", "pm_score": 10, "selected": true, "text": "stateComboBox.DropDownStyle = ComboBoxStyle.DropDownList;\n" }, { "answer_id": 26005210, "author": "invertigo", "author_id": 1241244, "author_profile": "https://Stackoverflow.com/users/1241244", "pm_score": 6, "selected": false, "text": "DropDownStyle" }, { "answer_id": 35766958, "author": "Abhishek Jaiswal", "author_id": 5275530, "author_profile": "https://Stackoverflow.com/users/5275530", "pm_score": 2, "selected": false, "text": "COMBOBOXID.DropDownStyle = ComboBoxStyle.DropDownList;\n" }, { "answer_id": 41678049, "author": "Diogo Rodrigues", "author_id": 3952930, "author_profile": "https://Stackoverflow.com/users/3952930", "pm_score": 1, "selected": false, "text": "VB.NET\nPrivate Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress\n e.Handled = True\nEnd Sub\n\n\n\nC#\nPrivate void ComboBox1_KeyPress(object sender, KeyPressEventArgs e)\n{\n e.Handled = true;\n}\n" }, { "answer_id": 71539504, "author": "lava", "author_id": 7706354, "author_profile": "https://Stackoverflow.com/users/7706354", "pm_score": 2, "selected": false, "text": "cmb_type.DropDownStyle=ComboBoxStyle.DropDownList\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3406/" ]
85,724
<p>I've got an Active Directory synchronization tool (.NET 2.0 / C#) written as a Windows Service that I've been working on for a while and have recently been tasked with adding the ability to drive events based on changes in group membership. The basic scenario is that users are synchronized with a security database and, when group membership changes, the users need to have their access rights changed (ie. if I am now a member of "IT Staff" then I should automatically receive access to the server room, if I am removed from that group then I should automatically lose access to the server room).</p> <p>The problem is that when doing a DirectorySynchronization against groups you receive back the group that has had a member added/removed, and from there when you grab the members list you get back the list of all members in that group currently not just the members that have been added or removed. This leads me to quite an efficiency problem - that being that in order to know if a user has been added or removed I will have to keep locally a list of each group and all members and compare that against the current list to see who has been added (not in local list), and who has been deleted (in local list, not in current members list). </p> <p>I'm debating just storing the group membership details in a DataSet in memory and writing to disk each time I've processed new membership changes. That way if the service stops/crashes or the machine is rebooted I can still get to the current state of the Active Directory within the security database by comparing the last information on disk to that from the current group membership list. However, this seems terrible inefficient - running through every member in the group to compare against what is in the dataset and then writing out changes to disk each time there are changes to the list.</p> <p>Has anyone dealt with this scenario before? Is there some way that I haven't found to retrieve only a delta of group members? What would you do in this situation to ensure that you never miss any changes while taking the smallest performance hit possible?</p> <p><strong>Edit:</strong> The AD might contain 500 users, it might contain 200,000 users - it depends on the customer, and on top of that how many groups the average user is a member of</p>
[ { "answer_id": 86141, "author": "Claus Thomsen", "author_id": 15555, "author_profile": "https://Stackoverflow.com/users/15555", "pm_score": 2, "selected": false, "text": " EventLog myLog = new EventLog(\"Security\");\n\n // set event handler\n myLog.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);\n myLog.EnableRaisingEvents = true;\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12063/" ]
85,726
<p>Is it possible to convert floating point exceptions (signals) into C++ exceptions on x86 Linux?</p> <p>This is for debugging purposes, so nonportability and imperfection is okay (e.g., if it isn't 100% guaranteed that all destructors are called).</p>
[ { "answer_id": 88829, "author": "jwfearn", "author_id": 10559, "author_profile": "https://Stackoverflow.com/users/10559", "pm_score": 3, "selected": false, "text": "fetestexcept" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16480/" ]
85,761
<p>I have an external variable coming in as a string and I would like to do a switch/case on it. How do I do that in xquery?</p>
[ { "answer_id": 85780, "author": "Sixty4Bit", "author_id": 1681, "author_profile": "https://Stackoverflow.com/users/1681", "pm_score": 2, "selected": false, "text": "let $str := \"kitchen\"\nlet $room := element {$str} {}\n" }, { "answer_id": 171837, "author": "Oliver Hallam", "author_id": 19995, "author_profile": "https://Stackoverflow.com/users/19995", "pm_score": 2, "selected": false, "text": "if ($room eq \"bathroom\") then \"loo\"\nelse if ($room eq \"kitchen\") then \"scullery\"\nelse \"just a room\"\n" }, { "answer_id": 2083615, "author": "Rafal Rusin", "author_id": 252891, "author_profile": "https://Stackoverflow.com/users/252891", "pm_score": 1, "selected": false, "text": "declare function a:fn($i) {\ntypeswitch ($i)\n case element(a:elemen1, xs:untyped) return 'a' \n case element(a:elemen2, xs:untyped) return 'b' \n default return \"error;\"\n};\n" }, { "answer_id": 2262130, "author": "Oliver Hallam", "author_id": 19995, "author_profile": "https://Stackoverflow.com/users/19995", "pm_score": 2, "selected": false, "text": "switch ($room) \n case \"bathroom\" return \"loo\"\n case \"kitchen\" return \"scullery\"\n default return \"just a room\"\n" }, { "answer_id": 2767036, "author": "jonathan robie", "author_id": 332581, "author_profile": "https://Stackoverflow.com/users/332581", "pm_score": 6, "selected": true, "text": "switch ($animal) \n case \"Cow\" return \"Moo\"\n case \"Cat\" return \"Meow\"\n case \"Duck\" return \"Quack\"\n default return \"What's that odd noise?\" \n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1681/" ]
85,770
<p>here is the input i am getting from my flash file </p> <p>process.php?Q2=898&amp;Aa=Grade1&amp;Tim=0%3A0%3A12&amp;Q1=908&amp;Bb=lkj&amp;Q4=jhj&amp;Q3=08&amp;Cc=North%20America&amp;Q0=1</p> <p>and in php i use this code foreach ($_GET as $field => $label) { $datarray[]=$_GET[$field];</p> <pre><code>echo "$field :"; echo $_GET[$field];; echo "&lt;br&gt;"; </code></pre> <p>i get this out put</p> <p>Q2 :898 Aa :Grade1 Tim :0:0:12 Q1 :908 Bb :lkj Q4 :jhj Q3 :08 Cc :North America Q0 :1</p> <p>now my question is how do i sort it alphabaticaly so it should look like this Aa :Grade1 Bb :lkj Cc :North America Q0 :1 Q1 :908</p> <p>and so on....before i can insert it into the DB</p>
[ { "answer_id": 85792, "author": "terminus", "author_id": 9232, "author_profile": "https://Stackoverflow.com/users/9232", "pm_score": 4, "selected": true, "text": "ksort($_GET);\n" }, { "answer_id": 85841, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 0, "selected": false, "text": "function knatsort(&$karr){\n $kkeyarr = array_keys($karr);\n natsort($kkeyarr);\n $ksortedarr = array();\n foreach($kkeyarr as $kcurrkey){\n $ksortedarr[$kcurrkey] = $karr[$kcurrkey];\n }\n $karr = $ksortedarr;\n return true;\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16458/" ]
85,773
<p>My source code needs to support both .NET version 1.1 and 2.0 ... how do I test for the different versions &amp; what is the best way to deal with this situation.</p> <p>I'm wondering if I should have the two sections of code inline, in separate classes, methods etc. What do you think?</p>
[ { "answer_id": 85902, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 2, "selected": true, "text": "#if NET11\n// .NET 1.1 code\n#elif NET20\n// .NET 2.0 code\n#endif\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
85,804
<p>Is there a better way to forcefully disconnect all users from an Oracle 10g database schema than restarting the Oracle database services?</p> <p>We have several developers using SQL Developer connecting to the same schema on a single Oracle 10g server. The problem is that when we want to drop the schema to rebuild it, inevitably someone is still connected and we cannot drop the database schema or the user while someone is still connected.</p> <p>By the same token, we do not want to drop all connections to other schemas because other people may still be connected and testing with those schemas.</p> <p>Anyone know of a quick way to resolve this?</p>
[ { "answer_id": 86739, "author": "Sten Vesterli", "author_id": 9363, "author_profile": "https://Stackoverflow.com/users/9363", "pm_score": 8, "selected": true, "text": "select sid,serial# from v$session where username = '<your_schema>'" }, { "answer_id": 9417191, "author": "LinuxQuestions.org", "author_id": 1213280, "author_profile": "https://Stackoverflow.com/users/1213280", "pm_score": 0, "selected": false, "text": "disconnect; \n\nconn tiger/scott as sysdba;\n" }, { "answer_id": 16643855, "author": "Chand Priyankara", "author_id": 251491, "author_profile": "https://Stackoverflow.com/users/251491", "pm_score": 4, "selected": false, "text": "SELECT s.inst_id,\n s.sid,\n s.serial#,\n p.spid,\n s.username,\n s.program\nFROM gv$session s\n JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id\nWHERE s.type != 'BACKGROUND';\n" }, { "answer_id": 20495895, "author": "RLapinski", "author_id": 1948391, "author_profile": "https://Stackoverflow.com/users/1948391", "pm_score": 3, "selected": false, "text": "DECLARE\n lc_username VARCHAR2 (32) := 'user-name-to-kill-here';\nBEGIN\n FOR ln_cur IN (SELECT sid, serial# FROM v$session WHERE username = lc_username)\n LOOP\n EXECUTE IMMEDIATE ('ALTER SYSTEM KILL SESSION ''' || ln_cur.sid || ',' || ln_cur.serial# || ''' IMMEDIATE');\n END LOOP;\nEND;\n/\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15766/" ]
85,815
<p>How do you tell if a function in JavaScript is defined?</p> <p>I want to do something like this</p> <pre><code>function something_cool(text, callback) { alert(text); if( callback != null ) callback(); } </code></pre> <p>But it gets me a</p> <blockquote> <p>callback is not a function</p> </blockquote> <p>error when callback is not defined.</p>
[ { "answer_id": 85822, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 10, "selected": true, "text": "typeof callback === \"function\"\n" }, { "answer_id": 85825, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 3, "selected": false, "text": "if (typeof(callback) == 'function')\n" }, { "answer_id": 85838, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "typeof(callback) == \"function\"\n" }, { "answer_id": 85849, "author": "Brian", "author_id": 16457, "author_profile": "https://Stackoverflow.com/users/16457", "pm_score": 2, "selected": false, "text": "if (!(typeof(callback)=='undefined')) {...}\n" }, { "answer_id": 85899, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 2, "selected": false, "text": "function something_cool(text, callback){\n alert(text);\n if(typeof(callback)=='function'){ \n callback(); \n };\n}\n" }, { "answer_id": 85946, "author": "Robin like the bird", "author_id": 14405, "author_profile": "https://Stackoverflow.com/users/14405", "pm_score": 4, "selected": false, "text": "if (callback && typeof(callback) == \"function\")\n" }, { "answer_id": 85973, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 8, "selected": false, "text": "function isFunction(possibleFunction) {\n return typeof(possibleFunction) === typeof(Function);\n}\n" }, { "answer_id": 88475, "author": "Andrew Hedges", "author_id": 11577, "author_profile": "https://Stackoverflow.com/users/11577", "pm_score": 2, "selected": false, "text": "if ('function' === typeof callback) ...\n" }, { "answer_id": 3762574, "author": "patriciorocca", "author_id": 427890, "author_profile": "https://Stackoverflow.com/users/427890", "pm_score": 3, "selected": false, "text": "function isFunctionDefined(functionName) {\n if(eval(\"typeof(\" + functionName + \") == typeof(Function)\")) {\n return true;\n }\n}\n\nif (isFunctionDefined('myFunction')) {\n myFunction(foo);\n}\n" }, { "answer_id": 10524738, "author": "eWolf", "author_id": 96603, "author_profile": "https://Stackoverflow.com/users/96603", "pm_score": 2, "selected": false, "text": "callback instanceof Function\n" }, { "answer_id": 23370622, "author": "Russell Ormes", "author_id": 2969567, "author_profile": "https://Stackoverflow.com/users/2969567", "pm_score": 3, "selected": false, "text": "function isFunction(possibleFunction) {\n return (typeof(possibleFunction) == typeof(Function));\n}\n" }, { "answer_id": 28120634, "author": "Quentin Engles", "author_id": 1451600, "author_profile": "https://Stackoverflow.com/users/1451600", "pm_score": 3, "selected": false, "text": "try{\n callback();\n}catch(e){};\n" }, { "answer_id": 28202317, "author": "Sudheer Aedama", "author_id": 1332911, "author_profile": "https://Stackoverflow.com/users/1332911", "pm_score": 1, "selected": false, "text": "_.isFunction(callback);\n" }, { "answer_id": 30647198, "author": "miguelmpn", "author_id": 2641352, "author_profile": "https://Stackoverflow.com/users/2641352", "pm_score": 1, "selected": false, "text": "if(typeof jQuery.fn.datepicker !== \"undefined\")\n" }, { "answer_id": 34863212, "author": "Samir Alajmovic", "author_id": 1645369, "author_profile": "https://Stackoverflow.com/users/1645369", "pm_score": -1, "selected": false, "text": "function something_cool(text, callback){\n callback && callback();\n}\n" }, { "answer_id": 36669851, "author": "VentyCZ", "author_id": 2178127, "author_profile": "https://Stackoverflow.com/users/2178127", "pm_score": 2, "selected": false, "text": "_.isFunction = function(obj) {\n return typeof obj == 'function' || false;\n};\n" }, { "answer_id": 46743214, "author": "Nick Tsai", "author_id": 4767939, "author_profile": "https://Stackoverflow.com/users/4767939", "pm_score": 1, "selected": false, "text": "callback()" }, { "answer_id": 46743451, "author": "inf3rno", "author_id": 607033, "author_profile": "https://Stackoverflow.com/users/607033", "pm_score": 0, "selected": false, "text": "eval" }, { "answer_id": 48353446, "author": "TexWiller", "author_id": 457043, "author_profile": "https://Stackoverflow.com/users/457043", "pm_score": 0, "selected": false, "text": "function myFunction() {\n var x=1;\n }" }, { "answer_id": 57274441, "author": "David Spector", "author_id": 2184308, "author_profile": "https://Stackoverflow.com/users/2184308", "pm_score": 0, "selected": false, "text": "A=function() {...} // first definition\n...\nif (typeof A==='function')\n oldA=A;\nA=function() {...oldA()...} // new definition\n" }, { "answer_id": 57876373, "author": "Patrick Ogbuitepu", "author_id": 11969299, "author_profile": "https://Stackoverflow.com/users/11969299", "pm_score": 0, "selected": false, "text": "if( cb && typeof( eval( cb ) ) === \"function\" ){\n eval( cb + \"()\" );\n}\n" }, { "answer_id": 68829303, "author": "Michel Casabianca", "author_id": 1294047, "author_profile": "https://Stackoverflow.com/users/1294047", "pm_score": -1, "selected": false, "text": "function isFunction(name) {\n return eval(`typeof ${name} === typeof Function`);\n}\n" }, { "answer_id": 71755388, "author": "Darren G", "author_id": 10302934, "author_profile": "https://Stackoverflow.com/users/10302934", "pm_score": 2, "selected": false, "text": "function something_cool(text, callback) {\n alert(text);\n callback?.();\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8351/" ]
85,816
<p>I've got just one page that I want to force to be accessed as an HTTPS page (PHP on Apache). How do I do this without making the whole directory require HTTPS? Or, if you submit a form to an HTTPS page from an HTTP page, does it send it by HTTPS instead of HTTP?</p> <p>Here is my example:</p> <pre><code>http://www.example.com/some-page.php </code></pre> <p>I want it to only be accessed through:</p> <pre><code>https://www.example.com/some-page.php </code></pre> <p>Sure, I can put all of the links to this page pointed at the HTTPS version, but that doesn't stop some fool from accessing it through HTTP on purpose...</p> <p>One thing I thought was putting a redirect in the header of the PHP file to check to be sure that they are accessing the HTTPS version:</p> <pre><code>if($_SERVER[&quot;SCRIPT_URI&quot;] == &quot;http://www.example.com/some-page.php&quot;){ header('Location: https://www.example.com/some-page.php'); } </code></pre> <p>But that can't be the right way, can it?</p>
[ { "answer_id": 85835, "author": "thebigjc", "author_id": 16507, "author_profile": "https://Stackoverflow.com/users/16507", "pm_score": 6, "selected": false, "text": "<Location /buyCrap.php>\nRewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}\n</Location>\n" }, { "answer_id": 85846, "author": "DGM", "author_id": 14253, "author_profile": "https://Stackoverflow.com/users/14253", "pm_score": 2, "selected": false, "text": "$_SERVER['HTTPS']" }, { "answer_id": 4520249, "author": "Jeff", "author_id": 552545, "author_profile": "https://Stackoverflow.com/users/552545", "pm_score": 3, "selected": false, "text": "// Force HTTPS for security\nif($_SERVER[\"HTTPS\"] != \"on\") {\n $pageURL = \"Location: https://\";\n if ($_SERVER[\"SERVER_PORT\"] != \"80\") {\n $pageURL .= $_SERVER[\"SERVER_NAME\"] . \":\" . $_SERVER[\"SERVER_PORT\"] . $_SERVER[\"REQUEST_URI\"];\n } else {\n $pageURL .= $_SERVER[\"SERVER_NAME\"] . $_SERVER[\"REQUEST_URI\"];\n }\n header($pageURL);\n}\n" }, { "answer_id": 12145293, "author": "Jacob Swartwood", "author_id": 777919, "author_profile": "https://Stackoverflow.com/users/777919", "pm_score": 5, "selected": false, "text": "// Use HTTP Strict Transport Security to force client to use secure connections only\n$use_sts = true;\n\n// iis sets HTTPS to 'off' for non-SSL requests\nif ($use_sts && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {\n header('Strict-Transport-Security: max-age=31536000');\n} elseif ($use_sts) {\n header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301);\n // we are in cleartext at the moment, prevent further execution and output\n die();\n}\n" }, { "answer_id": 14072023, "author": "itsazzad", "author_id": 540144, "author_profile": "https://Stackoverflow.com/users/540144", "pm_score": 3, "selected": false, "text": "RewriteEngine On \nRewriteCond %{SERVER_PORT} 80 \nRewriteRule ^(.*)$ https://www.example.com/$1 [R,L]\n" }, { "answer_id": 26090961, "author": "Spell", "author_id": 3774510, "author_profile": "https://Stackoverflow.com/users/3774510", "pm_score": -1, "selected": false, "text": "<?php \n// Require https\nif ($_SERVER['HTTPS'] != \"on\") {\n $url = \"https://\". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];\n header(\"Location: $url\");\n exit;\n}\n?>\n" }, { "answer_id": 27556415, "author": "syvex", "author_id": 766172, "author_profile": "https://Stackoverflow.com/users/766172", "pm_score": 3, "selected": false, "text": "function isSecure() {\n return (\n (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')\n || $_SERVER['SERVER_PORT'] == 443\n || (\n (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')\n || (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')\n )\n );\n}\n\nfunction requireHTTPS() {\n if (!isSecure()) {\n header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], TRUE, 301);\n exit;\n }\n}\n" }, { "answer_id": 30655191, "author": "JSG", "author_id": 1642731, "author_profile": "https://Stackoverflow.com/users/1642731", "pm_score": 3, "selected": false, "text": "RewriteEngine On\nRewriteCond %{SERVER_PORT} 80\nRewriteRule ^(.*)$ https://example.com/$1 [R,L]\n" }, { "answer_id": 31000510, "author": "MatHatrik", "author_id": 4614534, "author_profile": "https://Stackoverflow.com/users/4614534", "pm_score": 4, "selected": false, "text": "RewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}\n" }, { "answer_id": 38579223, "author": "Esteban Gallego", "author_id": 4545688, "author_profile": "https://Stackoverflow.com/users/4545688", "pm_score": -1, "selected": false, "text": "if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == \"off\"){\n $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];\n enter code hereheader('HTTP/1.1 301 Moved Permanently');\n header('Location: ' . $redirect);\n exit();\n}\n" }, { "answer_id": 38741015, "author": "Antonio", "author_id": 6090211, "author_profile": "https://Stackoverflow.com/users/6090211", "pm_score": 1, "selected": false, "text": "RewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n" }, { "answer_id": 38997081, "author": "bourax webmaster", "author_id": 2923903, "author_profile": "https://Stackoverflow.com/users/2923903", "pm_score": 1, "selected": false, "text": "if($_SERVER[\"HTTPS\"] != \"on\")\n{\n header(\"Location: https://\" . $_SERVER[\"HTTP_HOST\"] . $_SERVER[\"REQUEST_URI\"]);\n exit();\n}\n" }, { "answer_id": 39238967, "author": "Tarik", "author_id": 5105831, "author_profile": "https://Stackoverflow.com/users/5105831", "pm_score": 1, "selected": false, "text": "if (stripos(substr($_SERVER[SCRIPT_URI], 0, 5), \"https\") === false) {\n header(\"location:https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]\");\n echo \"<meta http-equiv='refresh' content='0; url=https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]'>\";\n exit;\n}\n" }, { "answer_id": 43251052, "author": "Tschallacka", "author_id": 1356107, "author_profile": "https://Stackoverflow.com/users/1356107", "pm_score": 1, "selected": false, "text": "<httpProtocol>\n <customHeaders>\n <add name=\"Strict-Transport-Security\" value=\"max-age=31536000\"/>\n </customHeaders>\n</httpProtocol>\n<rewrite>\n <rules>\n <rule name=\"HTTP to HTTPS redirect\" stopProcessing=\"true\">\n <match url=\"(.*)\" />\n <conditions>\n <add input=\"{HTTPS}\" pattern=\"off\" ignoreCase=\"true\" />\n </conditions>\n <action type=\"Redirect\" redirectType=\"Found\" url=\"https://{HTTP_HOST}/{R:1}\" />\n </rule>\n </rules>\n</rewrite>\n" }, { "answer_id": 49874887, "author": "Héouais Mongars", "author_id": 9575477, "author_profile": "https://Stackoverflow.com/users/9575477", "pm_score": 0, "selected": false, "text": "$protocol = $_SERVER[\"HTTP_CF_VISITOR\"];\n\nif (!strstr($protocol, 'https')){\n header(\"Location: https://\" . $_SERVER[\"HTTP_HOST\"] . $_SERVER[\"REQUEST_URI\"]);\n exit();\n}\n" }, { "answer_id": 53017189, "author": "Jay", "author_id": 9492841, "author_profile": "https://Stackoverflow.com/users/9492841", "pm_score": 3, "selected": false, "text": "$is_https=false;\nif (isset($_SERVER['HTTPS'])) $is_https=$_SERVER['HTTPS'];\nif ($is_https !== \"on\")\n{\n header(\"Location: https://\".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);\n exit(1);\n}\n" }, { "answer_id": 62680152, "author": "squiremaldoon", "author_id": 13735231, "author_profile": "https://Stackoverflow.com/users/13735231", "pm_score": 2, "selected": false, "text": "\n<?php\n\nif(!isset($_SERVER[\"HTTPS\"]) || $_SERVER[\"HTTPS\"] != \"on\") {\n header(\"Location: https://\" . $_SERVER[\"HTTP_HOST\"] . $_SERVER[\"REQUEST_URI\"], true, 301);\n //Prevent the rest of the script from executing.\n exit;\n}\n?>\n\n" }, { "answer_id": 65564968, "author": "Sumithran", "author_id": 6562458, "author_profile": "https://Stackoverflow.com/users/6562458", "pm_score": 1, "selected": false, "text": "X-Forwarded-Proto" }, { "answer_id": 68150501, "author": "MRRaja", "author_id": 2357497, "author_profile": "https://Stackoverflow.com/users/2357497", "pm_score": 1, "selected": false, "text": "if(location.protocol!=='https:'){location.replace(`https:${location.href.substring(location.protocol.length)}`);}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
85,880
<p>Currently I'm doing some unit tests which are executed from bash. Unit tests are initialized, executed and cleaned up in a bash script. This script usualy contains an init(), execute() and cleanup() functions. But they are not mandatory. I'd like to test if they are or are not defined.</p> <p>I did this previously by greping and seding the source, but it seemed wrong. Is there a more elegant way to do this?</p> <p>Edit: The following sniplet works like a charm:</p> <pre><code>fn_exists() { LC_ALL=C type $1 | grep -q 'shell function' } </code></pre>
[ { "answer_id": 85903, "author": "JBB", "author_id": 12332, "author_profile": "https://Stackoverflow.com/users/12332", "pm_score": 9, "selected": true, "text": "[[ $(type -t foo) == function ]] && echo \"Foo exists\"" }, { "answer_id": 85932, "author": "Allan Wind", "author_id": 9706, "author_profile": "https://Stackoverflow.com/users/9706", "pm_score": 7, "selected": false, "text": "declare" }, { "answer_id": 1540824, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "fn_exists()\n{\n type $1 2>/dev/null | grep -q 'is a function'\n}\n" }, { "answer_id": 1540934, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "fn_exists()\n{\n type $1 >/dev/null 2>&1;\n}\n" }, { "answer_id": 2253065, "author": "jonathanserafini", "author_id": 238290, "author_profile": "https://Stackoverflow.com/users/238290", "pm_score": 4, "selected": false, "text": "test_declare () {\n a () { echo 'a' ;}\n\n declare -f a > /dev/null\n}\n\ntest_type () {\n a () { echo 'a' ;}\n type a | grep -q 'is a function'\n}\n\necho 'declare'\ntime for i in $(seq 1 1000); do test_declare; done\necho 'type'\ntime for i in $(seq 1 100); do test_type; done\n" }, { "answer_id": 3121473, "author": "Noah Spurrier", "author_id": 319432, "author_profile": "https://Stackoverflow.com/users/319432", "pm_score": 0, "selected": false, "text": "test_function () {\n ! type -f $1 >/dev/null 2>&1 && type -t $1 >/dev/null 2>&1\n}\n" }, { "answer_id": 9002012, "author": "Grégory Joseph", "author_id": 302789, "author_profile": "https://Stackoverflow.com/users/302789", "pm_score": 4, "selected": false, "text": "fn_exists() {\n # appended double quote is an ugly trick to make sure we do get a string -- if $1 is not a known command, type does not output anything\n [ `type -t $1`\"\" == 'function' ]\n}\n" }, { "answer_id": 9466683, "author": "b1r3k", "author_id": 216172, "author_profile": "https://Stackoverflow.com/users/216172", "pm_score": 2, "selected": false, "text": "function is_executable()\n{\n typeset TYPE_RESULT=\"`type -t $1`\"\n\n if [ \"$TYPE_RESULT\" == 'function' ]; then\n return 0\n else\n return 1\n fi\n}\n" }, { "answer_id": 9529981, "author": "Orwellophile", "author_id": 912236, "author_profile": "https://Stackoverflow.com/users/912236", "pm_score": 6, "selected": false, "text": "-f" }, { "answer_id": 10788804, "author": "Scott", "author_id": 1422241, "author_profile": "https://Stackoverflow.com/users/1422241", "pm_score": 3, "selected": false, "text": "isFunction() { [[ \"$(declare -Ff \"$1\")\" ]]; }\n" }, { "answer_id": 35117169, "author": "Yunus", "author_id": 3746411, "author_profile": "https://Stackoverflow.com/users/3746411", "pm_score": 2, "selected": false, "text": "fn_exists()\n{\n [[ $(type -t $1) == function ]] && return 0\n}\n" }, { "answer_id": 40693218, "author": "jarno", "author_id": 4414935, "author_profile": "https://Stackoverflow.com/users/4414935", "pm_score": 3, "selected": false, "text": "#!/bin/bash\n\ntest_declare () {\n declare -f f > /dev/null\n}\n\ntest_declare2 () {\n declare -F f > /dev/null\n}\n\ntest_type () {\n type -t f | grep -q 'function'\n}\n\ntest_type2 () {\n [[ $(type -t f) = function ]]\n}\n\nfuncs=(test_declare test_declare2 test_type test_type2)\n\ntest () {\n for i in $(seq 1 1000); do $1; done\n}\n\nf () {\necho 'This is a test function.'\necho 'This has more than one command.'\nreturn 0\n}\npost='(f is function)'\n\nfor j in 1 2 3; do\n\n for func in ${funcs[@]}; do\n echo $func $post\n time test $func\n echo exit code $?; echo\n done\n\n case $j in\n 1) unset -f f\n post='(f unset)'\n ;;\n 2) f='string'\n post='(f is string)'\n ;;\n esac\ndone\n" }, { "answer_id": 46691003, "author": "qneill", "author_id": 468252, "author_profile": "https://Stackoverflow.com/users/468252", "pm_score": 2, "selected": false, "text": "$ fn_exists() { test x$(type -t $1) = xfunction; }\n$ fn_exists func1 && echo yes || echo no\nno\n$ func1() { echo hi from func1; }\n$ func1\nhi from func1\n$ fn_exists func1 && echo yes || echo no\nyes\n" }, { "answer_id": 66111119, "author": "it3xl", "author_id": 390940, "author_profile": "https://Stackoverflow.com/users/390940", "pm_score": 2, "selected": false, "text": "my_function" }, { "answer_id": 73969344, "author": "k_vishwanath", "author_id": 6341379, "author_profile": "https://Stackoverflow.com/users/6341379", "pm_score": 0, "selected": false, "text": "fn_exists() { type -t $1 >/dev/null && echo 'exists'; }\nfn_exists() { declare -F $1 >/dev/null && echo 'exists'; }\nfn_exists() { typeset -F $1 >/dev/null && echo 'exists'; }\nfn_exists() { compgen -A function $1 >/dev/null && echo 'exists'; }\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9232/" ]