qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
85,892
<p>I'm trying to determine if there's a way in Visual Basic 2008 (Express edition if that matters) to do inline collection initialization, a la JavaScript or Python:</p> <pre><code>Dim oMapping As Dictionary(Of Integer, String) = {{1,"First"}, {2, "Second"}} </code></pre> <p>I know Visual Basic 2008 supports array initialization like this, but I can't seem to get it to work for collections... Do I have the syntax wrong, or is it just not implemented?</p>
[ { "answer_id": 29078431, "author": "James Lawruk", "author_id": 88204, "author_profile": "https://Stackoverflow.com/users/88204", "pm_score": 3, "selected": false, "text": "Dim list As New List(Of String) From {\"First\", \"Second\"}\n Dim oMapping As New Dictionary(Of Integer, String) From {{1, \"First\"}, {2, \"Second\"}}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7542/" ]
85,916
<p>I'm looking for a Ruby's equivalent of <a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html" rel="nofollow noreferrer">Code Like a Pythonista: Idiomatic Python</a></p> <p>Desirable features:</p> <ul> <li>easy to read</li> <li>single document which covers all topics: tips, tricks, guidelines, caveats, and pitfalls</li> <li>size less than a book</li> <li>idioms should work out of the box for the standard distribution (<code>% sudo apt-get install ruby irb rdoc</code>)</li> </ul> <p>Please, put one tutorial per answer if possible, with an example code from the tutorial and its meaning.</p> <p>UPDATE:</p> <p>These are the most closest to the above description resources I've encountered:</p> <ul> <li><a href="http://blog.angelbob.com/posts/244" rel="nofollow noreferrer">Ruby Idioms</a></li> <li><a href="http://www.rubyist.net/~slagell/ruby/index.html" rel="nofollow noreferrer">Ruby User's Guide</a></li> </ul>
[ { "answer_id": 86205, "author": "AShelly", "author_id": 10396, "author_profile": "https://Stackoverflow.com/users/10396", "pm_score": 3, "selected": false, "text": "until while not x = x * 2 until x > 100\n" }, { "answer_id": 486370, "author": "assplecake", "author_id": 57198, "author_profile": "https://Stackoverflow.com/users/57198", "pm_score": 2, "selected": false, "text": "IO.foreach(\"textfile.txt\") {|line| puts line }\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4279/" ]
85,928
<p>Before I start, I know there is this post and it doesn't answer my question: <a href="https://stackoverflow.com/questions/3017/how-to-generate-getters-and-setters-in-visual-studio">How to generate getters and setters in Visual Studio?</a></p> <p>In Visual Studio 2008 there is the ability to auto generate getters and setters (accessors) by right clicking on a private variable -> Refactor -> Encapsulate Field...</p> <p>This is great for a class that has 2 or 3 methods, but come on MS! When have you ever worked with a class that has a few accessors?</p> <p>I am looking for a way to generate ALL with a few clicks (Eclipse folks out there will know what I am talking about - you can right click a class and select 'generate accessors'. DONE.). I really don't like spending 20 minutes a class clicking through wizards. I used to have some .NET 1.0 code that would generate classes, but it is long gone and this feature should really be standard for the IDE. </p> <p>UPDATE: I might mention that I have found Linq to Entities and SQLMetal to be really cool ideas, and way beyond my simple request in the paragraph above.</p>
[ { "answer_id": 85991, "author": "Eddie Deyo", "author_id": 9323, "author_profile": "https://Stackoverflow.com/users/9323", "pm_score": 2, "selected": false, "text": "public string SomeString { get; set; }\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8426/" ]
85,935
<p>I have an old .dot file with a few dozen styles in it.<br> I need to place them into <b>another .dot file </b> that I received. Is there a better way to get them in there than manually recreating each style?</p>
[ { "answer_id": 6180191, "author": "AIS", "author_id": 776717, "author_profile": "https://Stackoverflow.com/users/776717", "pm_score": 0, "selected": false, "text": "Go to Tools > Templates & Add-Ins... Click Organizer button..." } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
85,978
<p>For a given table 'foo', I need a query to generate a set of tables that have foreign keys that point to foo. I'm using Oracle 10G.</p>
[ { "answer_id": 86104, "author": "Mike Monette", "author_id": 6166, "author_profile": "https://Stackoverflow.com/users/6166", "pm_score": 7, "selected": true, "text": "select table_name\nfrom all_constraints\nwhere constraint_type='R'\nand r_constraint_name in \n (select constraint_name\n from all_constraints\n where constraint_type in ('P','U')\n and table_name='<your table here>'); \n" }, { "answer_id": 86128, "author": "Ethan Post", "author_id": 4527, "author_profile": "https://Stackoverflow.com/users/4527", "pm_score": 0, "selected": false, "text": "SELECT * FROM DICT WHERE TABLE_NAME LIKE '%CONS%';\n" }, { "answer_id": 86632, "author": "Tony R", "author_id": 12838, "author_profile": "https://Stackoverflow.com/users/12838", "pm_score": 1, "selected": false, "text": "select * from dictionary where table_name like 'ALL%' \n select 'alter table ' || TABLE_NAME || ' disable constraint ' || CONSTRAINT_NAME || ';'\nfrom all_constraints\nwhere constraint_type='R'\nand r_constraint_name in \n (select constraint_name\n from all_constraints\n where constraint_type in ('P','U')\n and table_name='<your table here>');\n" }, { "answer_id": 91402, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "SELECT level, main.table_name parent,\n link.table_name child\nFROM user_constraints main, user_constraints link \nWHERE main.constraint_type IN ('P', 'U')\nAND link.r_constraint_name = main.constraint_name\nSTART WITH main.table_name LIKE UPPER('&&table_name')\nCONNECT BY main.table_name = PRIOR link.table_name\nORDER BY level, main.table_name, link.table_name\n" }, { "answer_id": 23915533, "author": "matt1616", "author_id": 2371207, "author_profile": "https://Stackoverflow.com/users/2371207", "pm_score": 2, "selected": false, "text": "select * from user_cons_columns\nwhere constraint_name in (\n select constraint_name \n from all_constraints\n where constraint_type='R'\n and r_constraint_name in \n (select constraint_name\n from all_constraints\n where constraint_type in ('P','U')\n and table_name='<your table name here>'));\n" }, { "answer_id": 27227899, "author": "Abu Turab", "author_id": 4311521, "author_profile": "https://Stackoverflow.com/users/4311521", "pm_score": 0, "selected": false, "text": "select distinct table_name, constraint_name, column_name, r_table_name, position, constraint_type \nfrom (\n SELECT uc.table_name, \n uc.constraint_name, \n cols.column_name, \n (select table_name from user_constraints where constraint_name = uc.r_constraint_name) \n r_table_name,\n (select column_name from user_cons_columns where constraint_name = uc.r_constraint_name and position = cols.position) \n r_column_name,\n cols.position,\n uc.constraint_type\n FROM user_constraints uc\n inner join user_cons_columns cols on uc.constraint_name = cols.constraint_name \n where constraint_type != 'C'\n) \nstart with table_name = '&&tableName' and column_name = '&&columnName' \nconnect by nocycle \nprior table_name = r_table_name \nand prior column_name = r_column_name; \n" }, { "answer_id": 34919354, "author": "arvinq", "author_id": 2667361, "author_profile": "https://Stackoverflow.com/users/2667361", "pm_score": 1, "selected": false, "text": "SELECT a.table_name child_table, a.column_name child_column, a.constraint_name, \nb.table_name parent_table, b.column_name parent_column\nFROM all_cons_columns a\nJOIN all_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name\njoin all_cons_columns b on c.owner = b.owner and c.r_constraint_name = b.constraint_name\nWHERE c.constraint_type = 'R'\nAND a.table_name = 'your table name'\n" }, { "answer_id": 57193278, "author": "Hiram", "author_id": 4219715, "author_profile": "https://Stackoverflow.com/users/4219715", "pm_score": 0, "selected": false, "text": "select acc.table_name, acc.constraint_name \nfrom all_cons_columns acc\ninner join all_constraints ac\n on acc.constraint_name = ac.constraint_name\nwhere ac.r_constraint_name in (\n select constraint_name\n from all_constraints\n where table_name='yourTable'\n );\n" }, { "answer_id": 59678215, "author": "Mehmet Kurt", "author_id": 4924051, "author_profile": "https://Stackoverflow.com/users/4924051", "pm_score": 0, "selected": false, "text": "select \n\n uc.OWNER,\n uc.constraint_name as TableConstraint1,\n uc.r_constraint_name as TableConstraint2,\n uc.constraint_type as constrainttype1,\n us.constraint_type as constrainttype2,\n uc.table_name as Table1,us.table_name as Table2,\n ucc.column_name as TableColumn1, \n uccs.column_name as TableColumn2\nfrom user_constraints uc\n left outer join user_constraints us on uc.r_constraint_name = us.constraint_name\n left outer join USER_CONS_COLUMNS ucc on ucc.constraint_name = uc.constraint_name\n left outer join USER_CONS_COLUMNS uccs on uccs.constraint_name = us.constraint_name\nwhere uc.OWNER ='xxxx' and uc.table_name='xxxx' \n" }, { "answer_id": 66745159, "author": "Gh61", "author_id": 1341409, "author_profile": "https://Stackoverflow.com/users/1341409", "pm_score": 0, "selected": false, "text": "SELECT a.table_name child_table, a.column_name child_column, a.constraint_name, \nb.table_name parent_table, b.column_name parent_column\nFROM all_cons_columns a\nJOIN all_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name\nJOIN all_cons_columns b ON c.owner = b.owner AND c.r_constraint_name = b.constraint_name AND b.position = a.position\nWHERE c.constraint_type = 'R'\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
85,992
<p>How do I enumerate the properties of a JavaScript object?</p> <p>I actually want to list all the defined variables and their values, but I've learned that defining a variable actually creates a property of the window object.</p>
[ { "answer_id": 86014, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 11, "selected": true, "text": "for(var propertyName in myObject) {\n // propertyName is what you want\n // you can get the value like this: myObject[propertyName]\n}\n hasOwnProperty() hasOwnProperty() hasOwnProperty() jQuery.extend jQuery.fn.extend" }, { "answer_id": 86020, "author": "davenpcj", "author_id": 4777, "author_profile": "https://Stackoverflow.com/users/4777", "pm_score": 3, "selected": false, "text": "for (property in object) { // do stuff }" }, { "answer_id": 86306, "author": "Ryan Grove", "author_id": 14985, "author_profile": "https://Stackoverflow.com/users/14985", "pm_score": 8, "selected": false, "text": "for..in var myObject = {foo: 'bar'};\n\nfor (var name in myObject) {\n alert(name);\n}\n\n// results in a single alert of 'foo'\n\nObject.prototype.baz = 'quux';\n\nfor (var name in myObject) {\n alert(name);\n}\n\n// results in two alerts, one for 'foo' and one for 'baz'\n hasOwnProperty() for (var name in myObject) {\n if (myObject.hasOwnProperty(name)) {\n alert(name);\n }\n}\n hasOwnProperty() hasOwnProperty()" }, { "answer_id": 86877, "author": "Chase Seibert", "author_id": 7679, "author_profile": "https://Stackoverflow.com/users/7679", "pm_score": 2, "selected": false, "text": "var data = {name: 'Violet', occupation: 'character', age: 25, pets: ['frog', 'rabbit']};\nObject.toJSON(data);\n//-> '{\"name\": \"Violet\", \"occupation\": \"character\", \"age\": 25, \"pets\": [\"frog\",\"rabbit\"]}'\n" }, { "answer_id": 88482, "author": "Andrew Hedges", "author_id": 11577, "author_profile": "https://Stackoverflow.com/users/11577", "pm_score": 4, "selected": false, "text": "for (prop in obj) {\n alert(prop + ' = ' + obj[prop]);\n}\n" }, { "answer_id": 731883, "author": "cyberhobo", "author_id": 68638, "author_profile": "https://Stackoverflow.com/users/68638", "pm_score": 5, "selected": false, "text": "var myObject = { name: \"Cody\", status: \"Surprised\" };\nfor (var propertyName in myObject) {\n document.writeln( propertyName + \" : \" + myObject[propertyName] );\n}\n name : Cody\nstatus : Surprised\nforEach : function (obj, callback) {\n for (prop in obj) {\n if (obj.hasOwnProperty(prop) && typeof obj[prop] !== \"function\") {\n callback(prop);\n }\n }\n}\n Object.prototype.forEach = function (obj, callback) {\n for ( prop in obj ) {\n if ( obj.hasOwnProperty( prop ) && typeof obj[prop] !== \"function\" ) {\n callback( prop );\n }\n }\n};\n" }, { "answer_id": 2096099, "author": "Fabian Jakobs", "author_id": 129322, "author_profile": "https://Stackoverflow.com/users/129322", "pm_score": 6, "selected": false, "text": "for (var name in myObject) {\n alert(name);\n}\n var obj = { toString: 12};\nfor (var name in obj) {\n alert(name);\n}\n isPrototypeOf hasOwnProperty toLocaleString toString valueOf for (var key in myObject) {\n alert(key);\n}\n\nvar shadowedKeys = [\n \"isPrototypeOf\",\n \"hasOwnProperty\",\n \"toLocaleString\",\n \"toString\",\n \"valueOf\"\n];\nfor (var i=0, a=shadowedKeys, l=a.length; i<l; i++) {\n if map.hasOwnProperty(a[i])) {\n alert(a[i]);\n }\n}\n Object.keys(myObject)" }, { "answer_id": 11330279, "author": "EmRa228", "author_id": 1322034, "author_profile": "https://Stackoverflow.com/users/1322034", "pm_score": 4, "selected": false, "text": "for(var propertyName in myObject) {\n // propertyName is what you want.\n // You can get the value like this: myObject[propertyName]\n}\n jQuery.each(obj, function(key, value) {\n // key is what you want.\n // The value is in: value\n});\n" }, { "answer_id": 16120782, "author": "dkl", "author_id": 243263, "author_profile": "https://Stackoverflow.com/users/243263", "pm_score": 3, "selected": false, "text": "_.keys({one : 1, two : 2, three : 3});\n=> [\"one\", \"two\", \"three\"]\n" }, { "answer_id": 17591041, "author": "Chtioui Malek", "author_id": 1254684, "author_profile": "https://Stackoverflow.com/users/1254684", "pm_score": 4, "selected": false, "text": "var params = { name: 'myname', age: 'myage' }\n\nfor (var key in params) {\n alert(key + \"=\" + params[key]);\n}\n" }, { "answer_id": 19956872, "author": "Fabio Montefuscolo", "author_id": 1415639, "author_profile": "https://Stackoverflow.com/users/1415639", "pm_score": 3, "selected": false, "text": "function keys(){\n var k = [];\n for(var p in this) {\n if(this.hasOwnProperty(p))\n k.push(p);\n }\n return k;\n}\nObject.defineProperty(Object.prototype, \"keys\", { value : keys, enumerable:false });\n Object keys" }, { "answer_id": 36471341, "author": "Walle Cyril", "author_id": 3238046, "author_profile": "https://Stackoverflow.com/users/3238046", "pm_score": 3, "selected": false, "text": "for Object.keys(object1)" }, { "answer_id": 36922598, "author": "Felix Lapalme", "author_id": 2963024, "author_profile": "https://Stackoverflow.com/users/2963024", "pm_score": 1, "selected": false, "text": "getDescription(object, tabs) {\n var str = \"{\\n\";\n for (var x in object) {\n str += Array(tabs + 2).join(\"\\t\") + x + \": \";\n if (typeof object[x] === 'object' && object[x]) {\n str += this.getDescription(object[x], tabs + 1);\n } else {\n str += object[x];\n }\n str += \"\\n\";\n }\n str += Array(tabs + 1).join(\"\\t\") + \"}\";\n return str;\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4777/" ]
85,996
<p>I wrote myself a little downloading application so that I could easily grab a set of files from my server and put them all onto a new pc with a clean install of Windows, without actually going on the net. Unfortunately I'm having problems creating the folder I want to put them in and am unsure how to go about it.</p> <p>I want my program to download the apps to <code>program files\any name here\</code></p> <p>So basically I need a function that checks if a folder exists, and if it doesn't it creates it.</p>
[ { "answer_id": 86009, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 3, "selected": false, "text": "Directory.Exists(TheFolderName) Directory.CreateDirectory(TheFolderName) Imports System.IO" }, { "answer_id": 86016, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 9, "selected": true, "text": "If Not System.IO.Directory.Exists(YourPath) Then\n System.IO.Directory.CreateDirectory(YourPath)\nEnd If\n" }, { "answer_id": 86019, "author": "Guy Starbuck", "author_id": 2194, "author_profile": "https://Stackoverflow.com/users/2194", "pm_score": 4, "selected": false, "text": "Imports System\nImports System.IO\n\nPublic Class Test\n Public Shared Sub Main()\n ' Specify the directories you want to manipulate.\n Dim di As DirectoryInfo = New DirectoryInfo(\"c:\\MyDir\")\n Try\n ' Determine whether the directory exists.\n If di.Exists Then\n ' Indicate that it already exists.\n Console.WriteLine(\"That path exists already.\")\n Return\n End If\n\n ' Try to create the directory.\n di.Create()\n Console.WriteLine(\"The directory was created successfully.\")\n\n ' Delete the directory.\n di.Delete()\n Console.WriteLine(\"The directory was deleted successfully.\")\n\n Catch e As Exception\n Console.WriteLine(\"The process failed: {0}\", e.ToString())\n End Try\n End Sub\nEnd Class\n" }, { "answer_id": 86028, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 5, "selected": false, "text": "If Not Directory.Exists(path) Then\n Directory.CreateDirectory(path)\nEnd If\n" }, { "answer_id": 86212, "author": "Rick", "author_id": 163155, "author_profile": "https://Stackoverflow.com/users/163155", "pm_score": 4, "selected": false, "text": "Dim objFSO, strFolder\nstrFolder = \"C:\\Temp\"\nSet objFSO = CreateObject(\"Scripting.FileSystemObject\")\nIf Not objFSO.FolderExists(strFolder) Then\n objFSO.CreateFolder strFolder\nEnd If\n" }, { "answer_id": 1245879, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "If Not Directory.Exists(somePath) then\n Directory.CreateDirectory(somePath)\nEnd If\n" }, { "answer_id": 19409953, "author": "BaeFell", "author_id": 1832160, "author_profile": "https://Stackoverflow.com/users/1832160", "pm_score": 0, "selected": false, "text": " Dim sPath As String = \"Folder path here\"\n If (My.Computer.FileSystem.DirectoryExists(sPath) = False) Then\n My.Computer.FileSystem.CreateDirectory(sPath + \"/<Folder name>\")\n Else\n 'Something else happens, because the folder exists\n End If\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/85996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
86,002
<p>I need to write a Delphi application that pulls entries up from various tables in a database, and different entries will be in different currencies. Thus, I need to show a different number of decimal places and a different currency character for every Currency data type ($, Pounds, Euros, etc) depending on the currency of the item I've loaded.</p> <p>Is there a way to change the currency almost-globally, that is, for all Currency data shown in a form?</p>
[ { "answer_id": 87306, "author": "Francesca", "author_id": 9842, "author_profile": "https://Stackoverflow.com/users/9842", "pm_score": 4, "selected": true, "text": "function CurrFormatFromLCID(const AValue: Currency; const LCID: Integer = LOCALE_SYSTEM_DEFAULT): string;\nvar\n AFormatSettings: TFormatSettings;\nbegin\n GetLocaleFormatSettings(LCID, AFormatSettings);\n Result := CurrToStrF(AValue, ffCurrency, AFormatSettings.CurrencyDecimals, AFormatSettings);\nend;\n\nfunction USCurrFormat(const AValue: Currency): string;\nbegin\n Result := CurrFormatFromLCID(AValue, 1033); //1033 = US_LCID\nend;\n\nfunction FrenchCurrFormat(const AValue: Currency): string;\nbegin\n Result := CurrFormatFromLCID(AValue, 1036); //1036 = French_LCID\nend;\n\nprocedure TestIt;\nvar\n val: Currency;\nbegin\n val:=1234.56;\n ShowMessage('US: ' + USCurrFormat(val));\n ShowMessage('FR: ' + FrenchCurrFormat(val));\n ShowMessage('GB: ' + CurrFormatFromLCID(val, 2057)); // 2057 = GB_LCID\n ShowMessage('def: ' + CurrFormatFromLCID(val));\nend;\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42219/" ]
86,018
<p>If you are using HAML and SASS in your Rails application, then any templates you define in public/stylesheet/*.sass will be compiled into *.css stylesheets. From your code, you use stylesheet_link_tag to pull in the asset by name without having to worry about the extension. </p> <p>Many people dislike storing generated code or compiled code in version control, and it also stands to reason that the public/ directory shouldn't contain elements that you don't send to the browser. </p> <p>What is the best pattern to follow when laying out SASS resources in your Rails project?</p>
[ { "answer_id": 86457, "author": "mislav", "author_id": 11687, "author_profile": "https://Stackoverflow.com/users/11687", "pm_score": 5, "selected": true, "text": "/public/stylesheets/*.css\n" }, { "answer_id": 98772, "author": "Nate", "author_id": 12779, "author_profile": "https://Stackoverflow.com/users/12779", "pm_score": 3, "selected": false, "text": "public_html" }, { "answer_id": 106068, "author": "Ryan McGeary", "author_id": 8985, "author_profile": "https://Stackoverflow.com/users/8985", "pm_score": 3, "selected": false, "text": "after \"deploy:update_code\" do\n rails_env = fetch(:rails_env, \"production\")\n run \"#{release_path}/script/runner -e #{rails_env} 'Sass::Plugin.update_stylesheets'\"\nend\n" }, { "answer_id": 322954, "author": "chriseppstein", "author_id": 41221, "author_profile": "https://Stackoverflow.com/users/41221", "pm_score": 4, "selected": false, "text": "Sass::Plugin.options[:template_location] = {\n \"#{RAILS_ROOT}/app/stylesheets\" => \"#{RAILS_ROOT}/public/stylesheets/compiled\"\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13472/" ]
86,030
<p>I just finished a small project where changes were required to a pre-compiled, but no longer supported, ASP.NET web site. The code was ugly, but it was ugly before it was even compiled, and I'm quite impressed that everything still seems to work fine.</p> <p>It took some editing, e.g. to remove control declarations, as they get put in a generated file, and conflict with the decompiled base class, but nothing a few hours didn't cure.</p> <p>Now I'm just curious as to how many others have had how much success doing this. I would actually like to write a CodeProject article on defining, if not automating, the reverse engineering process. </p>
[ { "answer_id": 364287, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 0, "selected": false, "text": "<>" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
86,046
<p>I'm wondering the <em>best</em> way to start a pthread that is a member of a C++ class? My own approach follows as an answer...</p>
[ { "answer_id": 86253, "author": "ravenspoint", "author_id": 16582, "author_profile": "https://Stackoverflow.com/users/16582", "pm_score": 5, "selected": false, "text": "#include <boost/thread.hpp>\n\n// define class to model or control a particular kind of widget\nclass cWidget\n{\npublic:\nvoid Run();\n}\n\n// construct an instance of the widget modeller or controller\ncWidget theWidget;\n\n// start new thread by invoking method run on theWidget instance\n\nboost::thread* pThread = new boost::thread(\n &cWidget::Run, // pointer to member function to execute in thread\n &theWidget); // pointer to instance of class\n // define class to model or control a particular kind of widget\nclass cWidget\n{\npublic:\nvoid Run();\n}\n\n// construct an instance of the widget modeller or controller\ncWidget theWidget;\n\n// start new thread by invoking method run on theWidget instance\n\nstd::thread * pThread = new std::thread(\n &cWidget::Run, // pointer to member function to execute in thread\n &theWidget); // pointer to instance of class\n" }, { "answer_id": 2812499, "author": "Spille", "author_id": 338193, "author_profile": "https://Stackoverflow.com/users/338193", "pm_score": 0, "selected": false, "text": "#include <boost/thread.hpp>\n\nclass MyClass {\npublic:\n MyClass(int i);\n MyClass(const MyClass& myClass); // Copy-Constructor\n void operator()() const; // entry point for the new thread\n\n virtual void doSomething(); // Now you can use virtual functions\n\nprivate:\n int i; // and also fields very easily\n};\n MyClass clazz(1);\n// Passing the object directly will create a copy internally\n// Now you don't have to worry about the validity of the clazz object above\n// after starting the other thread\n// The operator() will be executed for the new thread.\nboost::thread thread(clazz); // create the object on the stack\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10774/" ]
86,049
<p>How do I ignore files in Subversion?</p> <p>Also, how do I find files which are not under version control?</p>
[ { "answer_id": 86052, "author": "andyuk", "author_id": 2108, "author_profile": "https://Stackoverflow.com/users/2108", "pm_score": 11, "selected": true, "text": "global-ignores global-ignores C:\\Users\\{you}\\AppData\\Roaming\\Subversion\\config Software\\Tigris.org\\Subversion\\Config\\Miscellany\\global-ignores HKLM HKCU ~/.subversion/config svn:ignore .gitignore svn:ignore svn:ignore cd ~/myRepoRoot # Open an existing repo.\necho \"foo\" > \"ignoreThis.txt\" # Create a file called \"ignoreThis.txt\".\n\nsvn status # Check to see if the file is ignored or not.\n> ? ./ignoreThis.txt\n> 1 unversioned file # ...it is NOT currently ignored.\n\nsvn propset svn:ignore \"ignoreThis.txt\" . # Apply the svn:ignore property to the \"myRepoRoot\" directory.\nsvn status\n> 0 unversioned files # ...but now the file is ignored!\n\ncd subdirectory # now open a subdirectory.\necho \"foo\" > \"ignoreThis.txt\" # create another file named \"ignoreThis.txt\".\n\nsvn status\n> ? ./subdirectory/ignoreThis.txt # ...and is is NOT ignored!\n> 1 unversioned file\n ./subdirectory/ignoreThis ignoreThis.txt . svn propset svn:ignore <filePattern> . --recursive <filePattern> <filePattern> . --recursive svn ignore pathToFileToIgnore.txt svn:global-ignores svn:ignore svn:ignore svn:global-ignores --recursive svn:global-ignores cd ~/myRepoRoot # Open an existing repo\necho \"foo\" > \"ignoreThis.txt\" # Create a file called \"ignoreThis.txt\"\nsvn status # Check to see if the file is ignored or not\n> ? ./ignoreThis.txt\n> 1 unversioned file # ...it is NOT currently ignored\n\nsvn propset svn:global-ignores \"ignoreThis.txt\" .\nsvn status\n> 0 unversioned files # ...but now the file is ignored!\n\ncd subdirectory # now open a subdirectory\necho \"foo\" > \"ignoreThis.txt\" # create another file named \"ignoreThis.txt\"\nsvn status\n> 0 unversioned files # the file is ignored here too!\n svn status global-ignores svn:ignore svn:global-ignores --no-ignore I grep svn status --no-ignore | grep \"^I\"\n svn status\n> ? foo # An unversioned file\n> M modifiedFile.txt # A versioned file that has been modified\n\nsvn status --no-ignore\n> ? foo # An unversioned file\n> I ignoreThis.txt # A file matching an svn:ignore pattern\n> M modifiedFile.txt # A versioned file that has been modified\n\nsvn status --no-ignore | grep \"^I\"\n> I ignoreThis.txt # A file matching an svn:ignore pattern\n" }, { "answer_id": 86067, "author": "DGM", "author_id": 14253, "author_profile": "https://Stackoverflow.com/users/14253", "pm_score": 2, "selected": false, "text": "svn status" }, { "answer_id": 86208, "author": "artur02", "author_id": 13937, "author_profile": "https://Stackoverflow.com/users/13937", "pm_score": 6, "selected": false, "text": "svn:ignore svn:ignore bin obj\n*.exe\n*.dll\n_ReSharper\n*.pdb\n*.suo\n" }, { "answer_id": 5155424, "author": "Kenneth", "author_id": 639428, "author_profile": "https://Stackoverflow.com/users/639428", "pm_score": 3, "selected": false, "text": "svn propset svn:ignore 'file1\nfile2' .\n" }, { "answer_id": 19593719, "author": "ulitosCoder", "author_id": 2321308, "author_profile": "https://Stackoverflow.com/users/2321308", "pm_score": 7, "selected": false, "text": "svn status | grep \"^\\?\" | awk \"{print \\$2}\" > ignoring.txt\n svn propset svn:ignore -F ignoring.txt .\n rm ignoring.txt\n svn ci --message \"ignoring some files\"\n svn proplist -v\n" }, { "answer_id": 22645123, "author": "d.danailov", "author_id": 609707, "author_profile": "https://Stackoverflow.com/users/609707", "pm_score": 5, "selected": false, "text": "/log\n\n/public/*.JPEG\n/public/*.jpeg\n/public/*.png\n/public/*.gif\n\n*.*~\n svn propset svn:ignore -F .svnignore .\n" }, { "answer_id": 25502141, "author": "Adrian Enriquez", "author_id": 3126509, "author_profile": "https://Stackoverflow.com/users/3126509", "pm_score": 6, "selected": false, "text": "svn propset svn:ignore -F ignorelist.txt .\n svn propset svn:ignore \"first\n second\n third\" .\n" }, { "answer_id": 28968259, "author": "Al Conrad", "author_id": 3457624, "author_profile": "https://Stackoverflow.com/users/3457624", "pm_score": 2, "selected": false, "text": "svn propset svn:ignore '\\*.*' .\n svn propset svn:ignore '*' .\n" }, { "answer_id": 30528955, "author": "bkbilly", "author_id": 4377632, "author_profile": "https://Stackoverflow.com/users/4377632", "pm_score": 3, "selected": false, "text": "svn st | awk '/^?/{print $2}' > svnignore.txt && svn propget svn:ignore >> svnignore.txt && svn propset svn:ignore -F svnignore.txt . && rm svnignore.txt\n svn st | awk '/^?/{print $2}' > svnignore.txt \nsvn propget svn:ignore >> svnignore.txt \nsvn propset svn:ignore -F svnignore.txt . \nrm svnignore.txt\n" }, { "answer_id": 40900988, "author": "LivingDust", "author_id": 2263095, "author_profile": "https://Stackoverflow.com/users/2263095", "pm_score": 3, "selected": false, "text": "svn st | awk '/^?/{print $2}' > svnignore.txt\nsvn propget svn:ignore >> svnignore.txt\nsvn propset svn:ignore -F svnignore.txt .\nrm svnignore.txt\n" }, { "answer_id": 45337863, "author": "Yorick", "author_id": 3954377, "author_profile": "https://Stackoverflow.com/users/3954377", "pm_score": 5, "selected": false, "text": "svn propedit svn:ignore .\n" }, { "answer_id": 48126740, "author": "Slack", "author_id": 9155608, "author_profile": "https://Stackoverflow.com/users/9155608", "pm_score": 2, "selected": false, "text": "ignore svn:ignore svn:ignore bin obj\n*.exe\n*.dll\n*.pdb\n*.suo\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2108/" ]
86,083
<p>I'm looking for libraries to:</p> <ul> <li>read and write meta data (for example ID3v2 tags in mp3 and all)</li> <li>convert compressed to to raw audio data and if possible raw audio data to mp3, ogg, aac, ...</li> <li>digitally process the audio data (energy, timbre, Mel Frequency Cepstral Coefficients - MFCC, FFT, LPC, Autocorrelation, Wavelet, ...)</li> </ul> <p>I already know and am not content with: </p> <ul> <li>JMF: original from Sun, reads mp3 and turns it into WAV. But does not read meta data nor provide any advanced digital processing features.</li> <li><a href="http://fmj-sf.net/" rel="noreferrer">FMJ</a>: Alternative implementation to JMF with same limitations.</li> <li><a href="http://jaudio.sourceforge.net/" rel="noreferrer">jAudio</a>: Not stable and although potential, currently not well maintained.</li> <li><a href="http://marsyas.sness.net/" rel="noreferrer">Marsyas</a>: In digital processing just what I had hoped for, but in C++. Maybe some port / integration already available?</li> <li><a href="http://jid3.blinkenlights.org/" rel="noreferrer">JID3</a>: API for meta data, but seems to be dead (last release 2005/12/10). </li> <li><a href="http://www.javazoom.net/javalayer/javalayer.html" rel="noreferrer">JLayer</a>: API for reading and playing, also dead (last update 2004/11/28).</li> <li><a href="http://www.routeconverter.de/MetaMusic/" rel="noreferrer">MetaMusic</a>: API of the program is neat but no official standalone open source project. Therefore has no community, future support and all...</li> <li><a href="http://www.lightdev.com/page/61.htm" rel="noreferrer">Light Dev</a>: Some interesting features, but not at all complete.</li> </ul> <p>This is what some of my own investigation has turned up. I would greatly appreciate all input, suggestions, critics, ...</p>
[ { "answer_id": 1685699, "author": "Art Clarke", "author_id": 204512, "author_profile": "https://Stackoverflow.com/users/204512", "pm_score": 2, "selected": false, "text": "* read and write meta data (for example ID3v2 tags in mp3 and all):\n * convert compressed to to raw audio data and if possible raw audio data to mp3, ogg, aac, ...\n * digitally process the audio data (energy, timbre, Mel Frequency Cepstral Coefficients - MFCC, FFT, LPC, Autocorrelation, Wavelet, ...)\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
86,105
<p>My web application has a login page that submits authentication credentials via an AJAX call. If the user enters the correct username and password, everything is fine, but if not, the following happens:</p> <ol> <li>The web server determines that although the request included a well-formed Authorization header, the credentials in the header do not successfully authenticate.</li> <li>The web server returns a 401 status code and includes one or more WWW-Authenticate headers listing the supported authentication types.</li> <li>The browser detects that the response to my call on the XMLHttpRequest object is a 401 and the response includes WWW-Authenticate headers. It then pops up an authentication dialog asking, again, for the username and password.</li> </ol> <p>This is all fine up until step 3. I don't want the dialog to pop up, I want want to handle the 401 response in my AJAX callback function. (For example, by displaying an error message on the login page.) I want the user to re-enter their username and password, of course, but I want them to see my friendly, reassuring login form, not the browser's ugly, default authentication dialog.</p> <p>Incidentally, I have no control over the server, so having it return a custom status code (i.e., something other than a 401) is not an option.</p> <p>Is there any way I can suppress the authentication dialog? In particular, can I suppress the Authentication Required dialog in Firefox 2 or later? Is there any way to suppress the Connect to <em>[host]</em> dialog in IE 6 and later?</p> <hr> <p><strong>Edit</strong><br> <em>Additional information from the author (Sept. 18):</em><br> I should add that the real problem with the browser's authentication dialog popping up is that it give insufficient information to the user.</p> <p>The user has just entered a username and password via the form on the login page, he believes he has typed them both correctly, and he has clicked the submit button or hit enter. His expectation is that he will be taken to the next page or perhaps told that he has entered his information incorrectly and should try again. However, he is instead presented with an unexpected dialog box.</p> <p>The dialog makes no acknowledgment of the fact he just <em>did</em> enter a username and password. It does not clearly state that there was a problem and that he should try again. Instead, the dialog box presents the user with cryptic information like "The site says: '<em>[realm]</em>'." Where <em>[realm]</em> is a short realm name that only a programmer could love.</p> <p>Web broswer designers take note: no one would ask how to suppress the authentication dialog if the dialog itself were simply more user-friendly. The <em>entire</em> reason that I am doing a login form is that our product management team rightly considers the browsers' authentication dialogs to be awful.</p>
[ { "answer_id": 170628, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "xmlHttp=new XMLHttpRequest();\nxmlHttp.mozBackgroundRequest = true;\nxmlHttp.open(\"GET\",URL,true,USERNAME,PASSWORD);\nxmlHttp.send(null);\n" }, { "answer_id": 20221330, "author": "Antoine Banctel-Chevrel", "author_id": 925683, "author_profile": "https://Stackoverflow.com/users/925683", "pm_score": 6, "selected": false, "text": "X-Requested-With: XMLHttpRequest www-authenticate X-Requested-With XMLHttpRequest" }, { "answer_id": 29082416, "author": "rustyx", "author_id": 485343, "author_profile": "https://Stackoverflow.com/users/485343", "pm_score": 4, "selected": false, "text": "WWW-Authenticate WWW-Authenticate WWW-Authenticate WWW-Authenticate" }, { "answer_id": 30511595, "author": "Clarence", "author_id": 752955, "author_profile": "https://Stackoverflow.com/users/752955", "pm_score": 1, "selected": false, "text": "<customErrors defaultRedirect=\"~/Error\" >\n <error statusCode=\"401\" redirect=\"~/Index\"/>\n</customErrors>\n DirectoryEntry entry = new DirectoryEntry(\"LDAP://OurDomain\");\n DirectorySearcher Dsearch = new DirectorySearcher(entry);\n Dsearch.Filter = \"(SAMAccountName=\" + UserID + \")\";\n Dsearch.PropertiesToLoad.Add(\"cn\");\n" }, { "answer_id": 37411994, "author": "Matas Vaitkevicius", "author_id": 1509764, "author_profile": "https://Stackoverflow.com/users/1509764", "pm_score": 0, "selected": false, "text": "ActionAttribute 400 401 public class NoBasicAuthDialogAuthorizeAttribute : AuthorizeAttribute\n{\n protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)\n {\n base.HandleUnauthorizedRequest(filterContext);\n filterContext.Result = new HttpStatusCodeResult(400);\n }\n}\n [NoBasicAuthDialogAuthorize(Roles = \"A-Team\")]\npublic ActionResult CarType()\n{\n // your code goes here\n}\n" }, { "answer_id": 46800995, "author": "John Knotts", "author_id": 6843807, "author_profile": "https://Stackoverflow.com/users/6843807", "pm_score": 1, "selected": false, "text": "www-authenticate (err, req, res, next) => {\n if (err) {\n res._headers['www-authenticate'] = ''\n return res.json(err)\n }\n}\n" }, { "answer_id": 65977195, "author": "Abdul Qadir Ahmed Abbasi", "author_id": 14200979, "author_profile": "https://Stackoverflow.com/users/14200979", "pm_score": 0, "selected": false, "text": "fetch('https://example.com', {\n credentials: 'omit'\n})" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9897/" ]
86,119
<p>I am trying to have Apache follow a symlink to a raid array server that will contain some large data files. I have tried modifying <code>httpd.conf</code> to have an entry like this</p> <pre><code>&lt;Directory "/Users/imagine/Sites"&gt; Options FollowSymLinks AllowOverride all Order allow,deny Allow from all &lt;/Directory&gt; </code></pre> <p>to have Apache follow any sym link in the Sites folder.</p> <p>I keep getting an error return that seems to indicate I don't have any permissions to access the files. The error is:</p> <blockquote> <p>Forbidden</p> <p>You don't have permission to access /~imagine/imageLibraryTest/videoClips/imageLibraryVideos/imageLibraryVideos/Data13/0002RT-1.mov on this server.</p> </blockquote> <p>The sys link file is the last "imageLibraryVideos" in the line with the Data13 being the sub dir on the server containing the file. </p> <p>The 0002RT-1.mov file hase these permissions:</p> <pre><code>-rwxrwxrwx 1 imagine staff 1138757 Sep 15 17:01 0002RT-1.mov </code></pre> <p>and is in this path:</p> <pre><code>cd /Volumes/ImagineProducts-1/Users/imagine/Sites/imageLibraryVideos/Data13 </code></pre> <p>the link points to:</p> <pre><code>lrwxr-xr-x 1 imagine staff 65 Sep 15 16:40 imageLibraryVideos -&gt; /Volumes/ImagineProducts-1/Users/imagine/Sites/imageLibraryVideos </code></pre>
[ { "answer_id": 86137, "author": "Alex M", "author_id": 9652, "author_profile": "https://Stackoverflow.com/users/9652", "pm_score": 1, "selected": false, "text": "drwx--x--x /var/log/apache2/error_log ServerRoot ErrorLog httpd.conf httpd.conf" }, { "answer_id": 86153, "author": "Michael Ridley", "author_id": 4838, "author_profile": "https://Stackoverflow.com/users/4838", "pm_score": 0, "selected": false, "text": "su - web-user web-user" }, { "answer_id": 321530, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 1, "selected": false, "text": "mount --rbind /path/to/current/location/somewhere/else /new/mount/point\n fstab /path/to/original /new/path bind defaults,bind 0 0\n" }, { "answer_id": 7155054, "author": "sebasuy", "author_id": 378400, "author_profile": "https://Stackoverflow.com/users/378400", "pm_score": 2, "selected": false, "text": "sudo -i -u www-data\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
86,129
<p>I can make a DAO recordset in VB6/Access do anything - add data, clean data, move data, get data dressed in the morning and take it to school. But I don't even know where to start in .NET. </p> <p>I'm not having any problems retrieving data from the database, but what do real people do when they need to edit data and put it back?</p> <p>What's the easiest and most direct way to edit, update and append data into related tables in .NET and SQL Server?</p>
[ { "answer_id": 86137, "author": "Alex M", "author_id": 9652, "author_profile": "https://Stackoverflow.com/users/9652", "pm_score": 1, "selected": false, "text": "drwx--x--x /var/log/apache2/error_log ServerRoot ErrorLog httpd.conf httpd.conf" }, { "answer_id": 86153, "author": "Michael Ridley", "author_id": 4838, "author_profile": "https://Stackoverflow.com/users/4838", "pm_score": 0, "selected": false, "text": "su - web-user web-user" }, { "answer_id": 321530, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 1, "selected": false, "text": "mount --rbind /path/to/current/location/somewhere/else /new/mount/point\n fstab /path/to/original /new/path bind defaults,bind 0 0\n" }, { "answer_id": 7155054, "author": "sebasuy", "author_id": 378400, "author_profile": "https://Stackoverflow.com/users/378400", "pm_score": 2, "selected": false, "text": "sudo -i -u www-data\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16415/" ]
86,138
<p>I need to get the default printer name. I'll be using C# but I suspect this is more of a framework question and isn't language specific.</p>
[ { "answer_id": 86185, "author": "OwenP", "author_id": 2547, "author_profile": "https://Stackoverflow.com/users/2547", "pm_score": 8, "selected": true, "text": "PrinterSettings PrinterSettings System.Drawing.Printing PrinterSettings settings = new PrinterSettings();\nConsole.WriteLine(settings.PrinterName); PrinterSettings.InstalledPrinters" }, { "answer_id": 86370, "author": "Nathan Baulch", "author_id": 8799, "author_profile": "https://Stackoverflow.com/users/8799", "pm_score": 5, "selected": false, "text": "public static string GetDefaultPrinterName()\n{\n var query = new ObjectQuery(\"SELECT * FROM Win32_Printer\");\n var searcher = new ManagementObjectSearcher(query);\n\n foreach (ManagementObject mo in searcher.Get())\n {\n if (((bool?) mo[\"Default\"]) ?? false)\n {\n return mo[\"Name\"] as string;\n }\n }\n\n return null;\n}\n" }, { "answer_id": 87349, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "using System;\nusing System.Management;\nnamespace Test\n{\n class Program\n {\n static void Main(string[] args)\n {\n ObjectQuery query = new ObjectQuery(\n \"Select * From Win32_Printer \" +\n \"Where Default = True\");\n\n ManagementObjectSearcher searcher =\n new ManagementObjectSearcher(query);\n\n foreach (ManagementObject mo in searcher.Get())\n {\n Console.WriteLine(mo[\"Name\"] + \"\\n\");\n\n foreach (PropertyData p in mo.Properties)\n {\n Console.WriteLine(p.Name );\n }\n }\n }\n }\n}\n" }, { "answer_id": 358979, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "PrintDialog PrinterName Try\n\n Dim _printDialog As New System.Windows.Forms.PrintDialog\n\n xPrinterName = _printDialog.PrinterSettings.PrinterName '= \"set as Default printer\"\n\nCatch ex As Exception\n System.Windows.Forms.MessageBox.Show(\"could not printed Label.\", \"Print Error\", MessageBoxButtons.OK, MessageBoxIcon.Error)\nEnd Try\n" }, { "answer_id": 9587897, "author": "Alexander Zwitbaum", "author_id": 104930, "author_profile": "https://Stackoverflow.com/users/104930", "pm_score": 3, "selected": false, "text": "string defaultPrinter;\nusing(var printServer = new LocalPrintServer()) {\n defaultPrinter = printServer.DefaultPrintQueue.FullName);\n}\n LocalPrintServer.GetDefaultPrintQueue().FullName\n" }, { "answer_id": 45630329, "author": "Ramgy Borja", "author_id": 7978302, "author_profile": "https://Stackoverflow.com/users/7978302", "pm_score": 2, "selected": false, "text": " PrinterSettings printerName = new PrinterSettings();\n\n string defaultPrinter;\n\n defaultPrinter = printerName.PrinterName;\n" }, { "answer_id": 56147272, "author": "Tahir Rehman", "author_id": 4407600, "author_profile": "https://Stackoverflow.com/users/4407600", "pm_score": 1, "selected": false, "text": "using System.Drawing.Printing; PrinterSettings settings = new PrinterSettings();\nstring defaultPrinterName = settings.PrinterName;" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7176/" ]
86,151
<p>Polyglot, or multiple language, solutions allow you to apply languages to problems which they are best suited for. Yet, at least in my experience, software shops tend to want to apply a "super" language to all aspects of the problem they are trying to solve. Sticking with that language come "hell or high water" even if another language is available which solves the problem simply and naturally. Why do you or do you not implement using polyglot solutions?</p>
[ { "answer_id": 179390, "author": "bugmagnet", "author_id": 426, "author_profile": "https://Stackoverflow.com/users/426", "pm_score": 2, "selected": false, "text": "Perl Statistics::Benford PDK GNAT ObjectAda MASM32 WinAsm libiconv Delphi libuninum C Visual C++ VB6 VBScript" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
86,163
<p>Reading through the Flickr API documentation it keeps stating I require an API key to use their REST protocols. I am only building a photo viewer, gathering information available from Flickr's <a href="http://www.flickr.com/services/feeds/docs/photos_public/" rel="noreferrer">public photo feed</a> (For instance, I am not planning on writing an upload script, where a API key would be required). <strong>Is there any added functionality I can get from getting a Key?</strong></p> <p><strong>Update</strong> I answered the question below</p>
[ { "answer_id": 101798, "author": "Jeff Winkworth", "author_id": 1306, "author_profile": "https://Stackoverflow.com/users/1306", "pm_score": 4, "selected": true, "text": "min_upload_date" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1306/" ]
86,171
<p><strong>First, a little background:</strong></p> <p>I'm displaying a data set with 288 rows and 8 columns (2304 records) using a ScrollableDataTable and the performance leaves a lot to be desired. An AJAX request that rerenders the control takes nearly 20 seconds to complete, compared to 7 seconds when rendering the same data using a DataTable control.</p> <p>Metrics captured via Servlet filters and JavaScript show that virtually all of the processing time is spent on the client-side. Out of a 19.87 second request, 3.87 seconds is spent on the server... with less than .6 seconds spent querying and sorting the data.</p> <p>Switching to a DataTable control cuts the request, response, and render cycle down to 1/3 of what I'm seeing with the ScrollableDataTable, but also removes several important features.</p> <p><strong>And now the question:</strong></p> <p>Has anyone else experienced performance issues with the ScrollableDataTable? What's the most efficient way to render large amounts of tabular data in JSF/RichFaces with pinned columns and two-axis scrolling?</p> <p><strong>Update:</strong></p> <p>We ended up writing a custom control. Full control over the rendered components and generated JavaScript allowed us achieve a response time comparable to the DataTable. I agree with Zack though - pagination is the correct answer.</p>
[ { "answer_id": 340818, "author": "Zack Marrapese", "author_id": 43222, "author_profile": "https://Stackoverflow.com/users/43222", "pm_score": 2, "selected": true, "text": "rich:dataTable rows reRender=\"paginator\" rich:datascroller" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5933/" ]
86,175
<p>On all my Windows servers, except for one machine, when I execute the following code to allocate a temporary files folder:</p> <pre><code>use CGI; my $tmpfile = new CGITempFile(1); print "tmpfile='", $tmpfile-&gt;as_string(), "'\n"; </code></pre> <p>The variable <code>$tmpfile</code> is assigned the value <code>'.\CGItemp1'</code> and this is what I want. But on one of my servers it's incorrectly set to <code>C:\temp\CGItemp1</code>.</p> <p>All the servers are running Windows 2003 Standard Edition, IIS6 and ActivePerl 5.8.8.822 (upgrading to later version of Perl not an option). The result is always the same when running a script from the command line or in IIS as a CGI script (where scriptmap <code>.pl</code> = <code>c:\perl\bin\perl.exe "%s" %s</code>).</p> <p>How I can fix this Perl installation and force it to return '<code>.\CGItemp1</code>' by default?</p> <p>I've even copied the whole Perl folder from one of the working servers to this machine but no joy.</p> <p><a href="https://stackoverflow.com/questions/86175/where-is-cgi-pm-supposed-to-create-temporary-files/86200#86200">@Hometoast:</a></p> <p>I checked the '<code>TMP</code>' and '<code>TEMP</code>' environment variables and also <code>$ENV{TMP}</code> and <code>$ENV{TEMP}</code> and they're identical. </p> <p>From command line they point to the user profile directory, for example: </p> <blockquote> <p><code>C:\DOCUME~1\[USERNAME]\LOCALS~1\Temp\1</code></p> </blockquote> <p>When run under IIS as a CGI script they both point to:</p> <blockquote> <p><code>c:\windows\temp</code></p> </blockquote> <p>In registry key <code>HKEY_USERS/.DEFAULT/Environment</code>, both servers have:</p> <blockquote> <p><code>%USERPROFILE%\Local Settings\Temp</code></p> </blockquote> <p>The ActiveState implementation of <code>CGITempFile()</code> is clearly using an alternative mechanism to determine how it should generate the temporary folder.</p> <p><a href="https://stackoverflow.com/questions/86175/where-is-cgi-pm-supposed-to-create-temporary-files/86993#86993">@Ranguard:</a></p> <p>The real problem is with the <code>CGI.pm</code> module and attachment handling. Whenever a file is uploaded to the site <code>CGI.pm</code> needs to store it somewhere temporary. To do this <code>CGITempFile()</code> is called within <code>CGI.pm</code> to allocate a temporary folder. So unfortunately I can't use <code>File::Temp</code>. Thanks anyway.</p> <p><a href="https://stackoverflow.com/questions/86175/where-is-cgi-pm-supposed-to-create-temporary-files/86874#86874">@Chris:</a></p> <p>That helped a bunch. I did have a quick scan through the <code>CGI.pm</code> source earlier but your suggestion made me go back and look at it more studiously to understand the underlying algorithm. I got things working, but the oddest thing is that there was originally no <code>c:\temp</code> folder on the server. </p> <p>To obtain a temporary fix I created a <code>c:\temp</code> folder and set the relevant permissions for the website's anonymous user account. But because this is a shared box I couldn't leave things that way, even though the temp files were being deleted. To cut a long story short, I renamed the <code>c:\temp</code> folder to something different and magically the correct '<code>.\</code>' folder path was being returned. I also noticed that the customer had enabled FrontPage extensions on the site, which removes write access for the anonymous user account on the website folders, so this permission needed re-applying. I'm still at a loss as to why at the start of this issue <code>CGITempFile()</code> was returning <code>c:\temp</code>, even though that folder didn't exist, and why it magically started working again.</p>
[ { "answer_id": 86874, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 4, "selected": true, "text": "$CGITempFile::TMPDIRECTORY find_tempdir find_tempdir" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]
86,202
<p>Does <a href="https://facelets.dev.java.net/" rel="nofollow noreferrer">Facelets</a> have any features for neater or more readable internationalised user interface text labels that what you can otherwise do using JSF?</p> <p>For example, with plain JSF, using h:outputFormat is a very verbose way to interpolate variables in messages.</p> <p><em>Clarification:</em> I know that I can add a message file entry that looks like:</p> <pre><code>label.widget.count = You have a total of {0} widgets. </code></pre> <p>and display this (if I'm using Seam) with:</p> <pre><code>&lt;h:outputFormat value="#{messages['label.widget.count']}"&gt; &lt;f:param value="#{widgetCount}"/&gt; &lt;/h:outputFormat&gt; </code></pre> <p>but that's a lot of clutter to output one sentence - just the sort of thing that gives JSF a bad name.</p>
[ { "answer_id": 100277, "author": "Peter Hilton", "author_id": 2670, "author_profile": "https://Stackoverflow.com/users/2670", "pm_score": 2, "selected": false, "text": "<h:outputText value=\"#{my:message('label.widget.count', widgetCount)}\"/>\n #{my:message('label.widget.count', widgetCount)}\n" }, { "answer_id": 100499, "author": "Sietse", "author_id": 6400, "author_profile": "https://Stackoverflow.com/users/6400", "pm_score": 3, "selected": false, "text": "label.widget.count = You have a total of #{widgetCount} widgets.\n <h:outputFormat value=\"#{messages['label.widget.count']}\" />\n" }, { "answer_id": 656391, "author": "Daan van Yperen", "author_id": 70262, "author_profile": "https://Stackoverflow.com/users/70262", "pm_score": 3, "selected": true, "text": "<ph:i18n key=\"label.widget.count\" p0=\"#{widgetCount}\"/>\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE facelet-taglib PUBLIC \"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN\" \"https://facelets.dev.java.net/source/browse/*checkout*/facelets/src/etc/facelet-taglib_1_0.dtd\">\n\n<facelet-taglib xmlns=\"http://java.sun.com/JSF/Facelet\">\n <namespace>http://peterhilton.com/core</namespace>\n\n <tag>\n <tag-name>i18n</tag-name>\n <source>i18n.xhtml</source>\n </tag>\n\n</facelet-taglib>\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<ui:composition xmlns=\"http://www.w3.org/1999/xhtml\"\n xmlns:ui=\"http://java.sun.com/jsf/facelets\"\n xmlns:h=\"http://java.sun.com/jsf/html\" \n xmlns:f=\"http://java.sun.com/jsf/core\">\n\n <h:outputFormat value=\"#{messages[key]}\">\n <!-- crude but it works -->\n <f:param value=\"#{p0}\" />\n <f:param value=\"#{p1}\" />\n <f:param value=\"#{p2}\" />\n <f:param value=\"#{p3}\" />\n </h:outputFormat>\n\n</ui:composition>\n <context-param>\n<param-name>facelets.LIBRARIES</param-name>\n<param-value>\n /components/ph.taglib.xml\n </param-value>\n</context-param>\n xmlns:ph=\"http://peterhilton.com/core\"" }, { "answer_id": 725362, "author": "Damo", "author_id": 2955, "author_profile": "https://Stackoverflow.com/users/2955", "pm_score": 2, "selected": false, "text": "<h:outputText value=\"#{interpolator.interpolate(messages['label.widget.count'], widgetCount)}\"/>\n" }, { "answer_id": 21808243, "author": "Grim", "author_id": 843943, "author_profile": "https://Stackoverflow.com/users/843943", "pm_score": 1, "selected": false, "text": "label.widget.count = You have a total of #{widgetCount} widgets.\nlabel.welcome.message = Welcome to #{request.contextPath}!\nlabel.welcome.url = Your path is ${pageContext.servletContext}.\n ${messages['label.widget.count']} package foo;\n\nimport javax.el.ELContext;\nimport javax.el.ELException;\nimport javax.el.ExpressionFactory;\nimport javax.el.ResourceBundleELResolver;\nimport javax.faces.context.FacesContext;\n\nimport org.springframework.web.jsf.el.SpringBeanFacesELResolver;\n\npublic class ELResolver extends SpringBeanFacesELResolver {\n private static final ExpressionFactory FACTORY = FacesContext\n .getCurrentInstance().getApplication().getExpressionFactory();\n private static final ResourceBundleELResolver RESOLVER = new ResourceBundleELResolver();\n\n @Override\n public Object getValue(ELContext elContext, Object base, Object property)\n throws ELException {\n Object result = super.getValue(elContext, base, property);\n if (result == null) {\n result = RESOLVER.getValue(elContext, base, property);\n if (result instanceof String) {\n String el = (String) result;\n if (el.contains(\"${\") | el.contains(\"#{\")) {\n result = FACTORY.createValueExpression(elContext, el,\n String.class).getValue(elContext);\n }\n }\n }\n return result;\n }\n}\n faces-config.xml org.springframework.web.jsf.el.SpringBeanFacesELResolver <el-resolver>foo.ELResolver</el-resolver>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2670/" ]
86,219
<p>Does anyone know of any 'standard' way to interface with a telephony system (think Cisco CCM) from a C/C++ app in *nix? I have used MS TAPI in the past but this is Windows only and don't want to go the jTAPI (Java) route, which seems to be the only option on the face of it.</p> <p>I want to monitor the phone system for logging purposes (so I know when users have made calls, received calls, etc.). TAPI is good at this sort of thing but I can't be the first person who wants to do something similar without having a Windows server.</p> <p>Note that I need to integrate with existing PABX systems - notably Cisco CCM and Nortel BCM.</p>
[ { "answer_id": 40348467, "author": "isapir", "author_id": 968244, "author_profile": "https://Stackoverflow.com/users/968244", "pm_score": 0, "selected": false, "text": "crontab #!/bin/sh\n\nHOST=\"192.168.0.200\"\nPORT=\"2300\"\nUSER=\"SMDR\"\nPASS=\"PCCSMDR\"\n\nFILE=/var/smdr/smdr-`date +%F`.log\nTS=`date +\"%F %T\"`\n\necho \"### ${TS}\" >> $FILE\n\n(\n echo open $HOST $PORT\n sleep 2\n echo $USER\n sleep 2\n echo $PASS\n sleep 150\n echo \"quit\"\n) | telnet | tee -a $FILE\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
86,220
<p>I have a Perl script that I'm attempting to set up using Perl Threads (use threads). When I run simple tests everything works, but when I do my actual script (which has the threads running multiple SQL<em>Plus sessions), each SQL</em>Plus session runs in order (i.e., thread 1's sqlplus runs steps 1-5, then thread 2's sqlplus runs steps 6-11, etc.).</p> <p>I thought I understood that threads would do concurrent processing, but something's amiss. Any ideas, or should I be doing some other Perl magic?</p>
[ { "answer_id": 89898, "author": "Brad Gilbert", "author_id": 1337, "author_profile": "https://Stackoverflow.com/users/1337", "pm_score": 1, "selected": false, "text": "threads::yield" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16575/" ]
86,262
<p>I normally run VS 2008 at home and LINQ is built in. At work we are still using VS 2005 and I have the opportunity to start a new project that I would like to use LINQ to SQL.</p> <p>After doing some searching all I could come up with was the MAY 2006 CTP of LINQ would have to be installed for LINQ to work in VS 2005.</p> <p>Does someone know the proper add ins or updates I would need to install to use LINQ in VS 2005 (preferably without having to use the CTP mentioned above).</p>
[ { "answer_id": 89898, "author": "Brad Gilbert", "author_id": 1337, "author_profile": "https://Stackoverflow.com/users/1337", "pm_score": 1, "selected": false, "text": "threads::yield" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7712/" ]
86,269
<p>So, I am seeing a curious problem. If I have a function</p> <pre><code>// counter wraps around to beginning eventually, omitted for clarity. var counter; cycleCharts(chartId) { // chartId should be undefined when called from setInterval console.log('chartId: ' + chartId); if(typeof chartId == 'undefined' || chartId &lt; 0) { next = counter++; } else { next = chartId; } // ... do stuff to display the next chart } </code></pre> <p>This function can be called explicitly by user action, in which case <code>chartId</code> is passed in as an argument, and the selected chart is shown; or it can be in autoplay mode, in which case it's called by a <code>setInterval</code> which is initialized by the following:</p> <pre><code>var cycleId = setInterval(cycleCharts, 10000); </code></pre> <p>The odd thing is, I'm actually seeing the <code>cycleCharts()</code> get a <code>chartId</code> argument even when it's called from <code>setInterval</code>! The <code>setInterval</code> doesn't even have any parameters to pass along to the <code>cycleCharts</code> function, so I'm very baffled as to why <code>chartId</code> is not undefined when <code>cycleCharts</code> is called from the <code>setInterval</code>.</p>
[ { "answer_id": 86309, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 3, "selected": true, "text": " var cycleId = setInterval(function(){ cycleCharts(); }, 10000); \n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13289/" ]
86,271
<p>I am attempting to find xml files with large swaths of commented out xml. I would like to programmatically search for xml comments that stretch beyond a given number of lines. Is there an easy way of doing this?</p>
[ { "answer_id": 86332, "author": "Sam", "author_id": 9406, "author_profile": "https://Stackoverflow.com/users/9406", "pm_score": 1, "selected": false, "text": "<!-- (.[^-->]|[\\r\\n][^-->]){5}(.[^-->]|[\\r\\n][^-->])*? -->\n" }, { "answer_id": 108475, "author": "Mattio", "author_id": 19626, "author_profile": "https://Stackoverflow.com/users/19626", "pm_score": 1, "selected": false, "text": "static void Main(string[] args)\n{\n string[] myFiles = { @\"C:\\temp\\XMLFile1.xml\", \n @\"C:\\temp\\XMLFile2.xml\", \n @\"C:\\temp\\XMLFile3.xml\" };\n int maxSize = 5;\n foreach (string file in myFiles)\n {\n System.Xml.XPath.XPathDocument myDoc = \n new System.Xml.XPath.XPathDocument(file);\n System.Xml.XPath.XPathNavigator myNav = \n myDoc.CreateNavigator();\n\n System.Xml.XPath.XPathNodeIterator nodes = myNav.Select(\"//comment()\");\n while (nodes.MoveNext())\n {\n if (nodes.Current.ToString().Length > maxSize)\n Console.WriteLine(file + \": Long comment length = \" + \n nodes.Current.ToString().Length);\n }\n\n\n }\n\n Console.ReadLine();\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
86,278
<p>I have searched around, and it seems that this is a limitation in MS Access, so I'm wondering what creative solutions other have found to this puzzle.</p> <p>If you have a continuous form and you want a field to be a combo box of options that are specific to that row, Access fails to deliver; the combo box row source is only queried once at the beginning of the form, and thus show the wrong options for the rest of the form.</p> <p>The next step we all try, of course, is to use the onCurrent event to requery the combo box, which does in fact limit the options to the given row. However, at this point, Access goes nuts, and requeries <em>all</em> of the combo boxes, for every row, and the result is often that of disappearing and reappearing options in other rows, depending on whether they have chosen an option that is valid for the current record's row source.</p> <p>The only solution I have found is to just list all options available, all the time. Any creative answers out there?</p> <p><strong>Edit</strong> Also, I should note that the reason for the combo box is to have a query as a lookup table, the real value needs to be hidden and stored, while the human readable version is displayed... multiple columns in the combo box row source. Thus, changing limit to list doesn't help, because id's that are not in the current row source query won't have a matching human readable part.</p> <p>In this particular case, continuous forms make a lot of sense, so please don't tell me it's the wrong solution. I'm asking for any creative answers. </p>
[ { "answer_id": 88772, "author": "David-W-Fenton", "author_id": 9787, "author_profile": "https://Stackoverflow.com/users/9787", "pm_score": 1, "selected": false, "text": "[MySubForm].[Form]!MyID\n" }, { "answer_id": 322563, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "If Nz(Me.Equipment, 0) > 0 Then\n Me.Manufacturer.RowSource = GetMfrSQL() '- gets filtered query based on Equipment\nElse\n Me.Manufacturer.RowSource = \"SELECT MfgrID, MfgrName FROM tblManufacturers ORDER BY MfgrName\"\nEnd If\n Me.Manufacturer.RowSource = \"SELECT MfgrID, MfgrName FROM tblManufacturers ORDER BY MfgrName\"\n If Nz(Me.EquipmentID, 0) = 0 Then\n '-- Must select Equipment first, before selecting Manufacturer\n Me.Equipment.SetFocus\nEnd If\n Me.sFrmEquip.Controls(\"Manufacturer\").RowSource = \"SELECT MfgrID, MfgrName FROM tblManufacturers ORDER BY MfgrName\"\n" }, { "answer_id": 2419599, "author": "Al Del Vecchio", "author_id": 290821, "author_profile": "https://Stackoverflow.com/users/290821", "pm_score": 0, "selected": false, "text": "OnEnter rowsource" }, { "answer_id": 9255837, "author": "XXX", "author_id": 1206073, "author_profile": "https://Stackoverflow.com/users/1206073", "pm_score": 1, "selected": false, "text": " Private Sub CBOsfrmTouchpoint8_Enter() \n\n If Me.CBOsfrmTouchpoint8.Tag = \"Yes\" Then \n CBOsfrmTouchpoint14.SetFocus \n Me.CBOsfrmTouchpoint8.Tag = \"No\" \n Exit Sub \n End If \n\n Me.CBOsfrmTouchpoint8.Tag = \"No\" \n Me.CBOsfrmTouchpoint8.RowSource = \"XXX\" \n Me.CBOsfrmTouchpoint8.Requery \n Me.CBOsfrmTouchpoint8.SetFocus \n End Sub \n\n Private Sub CBOsfrmTouchpoint8_GotFocus() \n Me.CBOsfrmTouchpoint14.Width = 0 \n Me.CBOsfrmTouchpoint8.Width = 3420 \n Me.CBOsfrmTouchpoint8.Left = 8580 \n Me.CBOsfrmTouchpoint8.Dropdown \n End Sub\n\n Private Sub CBOsfrmTouchpoint8_LostFocus() \n Me.CBOsfrmTouchpoint8.RowSource = \"XXX\" \n Me.CBOsfrmTouchpoint8.Requery \n End Sub \n\n Private Sub CBOsfrmTouchpoint8_Exit(Cancel As Integer) \n Me.CBOsfrmTouchpoint14.Width = 3180 \n Me.CBOsfrmTouchpoint8.Width = 240 \n Me.CBOsfrmTouchpoint8.Left = 11760 \n Me.CBOsfrmTouchpoint8.Tag = \"Yes\" \n End Sub\n" }, { "answer_id": 34681529, "author": "Steve", "author_id": 5763725, "author_profile": "https://Stackoverflow.com/users/5763725", "pm_score": 0, "selected": false, "text": "WHERE Client=Forms!frmMain!ClientTextBox On Enter ComboBox1.Requery" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14253/" ]
86,292
<p>I would much prefer to do this without catching an exception in <code>LoadXml()</code> and using this results as part of my logic. Any ideas for a solution that doesn't involve manually parsing the xml myself? I think VB has a return value of false for this function instead of throwing an XmlException. Xml input is provided from the user. Thanks much!</p> <pre><code>if (!loaded) { this.m_xTableStructure = new XmlDocument(); try { this.m_xTableStructure.LoadXml(input); loaded = true; } catch { loaded = false; } } </code></pre>
[ { "answer_id": 86341, "author": "Rasmus Faber", "author_id": 5542, "author_profile": "https://Stackoverflow.com/users/5542", "pm_score": 7, "selected": true, "text": "public class MyXmlDocument: XmlDocument\n{\n bool TryParseXml(string xml){\n try{\n ParseXml(xml);\n return true;\n }catch(XmlException e){\n return false;\n }\n }\n" }, { "answer_id": 1720130, "author": "Dan", "author_id": 4513447, "author_profile": "https://Stackoverflow.com/users/4513447", "pm_score": 3, "selected": false, "text": "public static bool IsValidXhtml(this string text)\n{\n bool errored = false;\n var reader = new XmlValidatingReader(text, XmlNodeType.Element, new XmlParserContext(null, new XmlNamespaceManager(new NameTable()), null, XmlSpace.None));\n reader.ValidationEventHandler += ((sender, e) => { errored = e.Severity == System.Xml.Schema.XmlSeverityType.Error; });\n\n while (reader.Read()) { ; }\n reader.Close();\n return !errored;\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1551/" ]
86,378
<p>I am looking into mechanisms for better search capabilities against our database. It is currently a huge bottleneck (causing long-lasting queries that are hurting our database performance).</p> <p>My boss wanted me to look into <a href="http://lucene.apache.org/solr/" rel="nofollow noreferrer">Solr</a>, but on closer inspection, it seems we actually want some kind of DB integration mechanism with Lucene itself.</p> <p>From the <a href="http://wiki.apache.org/lucene-java/LuceneFAQ#head-109358021acbfc89456e446740dc2bbf9049950f" rel="nofollow noreferrer">Lucene FAQ</a>, they recommend <a href="http://search.hibernate.org/" rel="nofollow noreferrer">Hibernate Search</a>, <a href="http://www.compass-project.org/" rel="nofollow noreferrer">Compass</a>, and <strike><a href="http://www.dbsight.net/" rel="nofollow noreferrer">DBSight</a></strike>.</p> <p>As a background of our current technology stack, we are using straight JSPs on Tomcat, no Hibernate, no other frameworks on top of it... just straight Java, JSP, and JDBC against a DB2 database.</p> <p>Given that, it seems Hibernate Search might be a bit more difficult to integrate into our system, though it might be nice to have the option of using Hibernate after such an integration.</p> <p>Does anyone have any experiences they can share with using one of these tools (or other similar Lucene based solutions) that might help in picking the right tool?</p> <p>It needs to be a FOSS solution, and ideally will manage updating Lucene with changes from the database automagicly (though efficiently), without extra effort to notify the tool when changes have been made (otherwise, it seems rolling my own Lucene solution would be just as good). Also, we have multiple application servers with just 1 database (+failover), so it would be nice if it is easy to use the solution from all application servers seamlessly.</p> <p>I am continuing to inspect the options now, but it would be really helpful to utilize other people's experiences.</p>
[ { "answer_id": 96566, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 2, "selected": false, "text": "Directory IndexReader" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
86,402
<p>Is my best be going to be a shell script which replaces symlinks with copies, or is there another way of telling Git to follow symlinks?</p> <p>PS: I know it's not very secure, but I only want to do it in a few specific cases.</p>
[ { "answer_id": 86459, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 7, "selected": true, "text": " /foo/\n /foo/baz\n /bar/foo --> /foo\n /bar/foo/baz\n git add /bar/foo/baz\n" }, { "answer_id": 405445, "author": "Erik Schnetter", "author_id": 50744, "author_profile": "https://Stackoverflow.com/users/50744", "pm_score": 4, "selected": false, "text": "git-add" }, { "answer_id": 1199898, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "# Adds the symlink itself\n$ git add symlink\n\n# Follows symlink and adds the denoted directory's contents\n$ git add symlink/\n" }, { "answer_id": 2079380, "author": "user252400", "author_id": 252400, "author_profile": "https://Stackoverflow.com/users/252400", "pm_score": 7, "selected": false, "text": "sudo mount --bind SOURCEDIRECTORY TARGETDIRECTORY\n TARGETDIRECTORY SOURCEDIRECTORY /etc/fstab /sourcedir /targetdir none bind\n" }, { "answer_id": 2292682, "author": "J Chris A", "author_id": 242943, "author_profile": "https://Stackoverflow.com/users/242943", "pm_score": 2, "selected": false, "text": "mount --bind ln" }, { "answer_id": 5787312, "author": "spier", "author_id": 365712, "author_profile": "https://Stackoverflow.com/users/365712", "pm_score": 6, "selected": false, "text": "~/application config.conf config.conf ~/repos/application/config.conf ~/application ln -s ~/repos/application/config.conf" }, { "answer_id": 18692600, "author": "Abbafei", "author_id": 541412, "author_profile": "https://Stackoverflow.com/users/541412", "pm_score": 5, "selected": false, "text": ".git/hooks/pre-commit #!/bin/sh\n# (replace \"find .\" with \"find ./<path>\" below, to work with only specific paths)\n\n# (these lines are really all one line, on multiple lines for clarity)\n# ...find symlinks which do not dereference to directories...\nfind . -type l -exec test '!' -d {} ';' -print -exec sh -c \\\n# ...remove the symlink blob, and add the content diff, to the index/cache\n 'git rm --cached \"$1\"; diff -au /dev/null \"$1\" | git apply --cached -p1 -' \\\n# ...and call out to \"sh\".\n \"process_links_to_nondir\" {} ';'\n\n# the end\n diff -a" }, { "answer_id": 24275394, "author": "fregante", "author_id": 288906, "author_profile": "https://Stackoverflow.com/users/288906", "pm_score": 6, "selected": false, "text": "git hln source destination\n ln ln source destination\n mklink /j \"source\" \"destination\"\n" }, { "answer_id": 28848070, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": false, "text": "gitster apply path/to/dir/file path/to/dir path/to/dir path/to/dir/file path/to/dir path/to/dir path/to/dir/file link path/to/dir path/to/dir/file \"%s: patch does not apply\" affected file '%s' is beyond a symbolic link\n" }, { "answer_id": 54121082, "author": "ijoseph", "author_id": 588437, "author_profile": "https://Stackoverflow.com/users/588437", "pm_score": 4, "selected": false, "text": "git bindfs brew install bindfs cd /path/to/git_controlled_dir mkdir local_copy_dir bindfs </full/path/to/source_dir> </full/path/to/local_copy_dir>" }, { "answer_id": 63645471, "author": "Tenders McChiken", "author_id": 10126273, "author_profile": "https://Stackoverflow.com/users/10126273", "pm_score": 1, "selected": false, "text": "bwrap bwrap sudo bwrap --ro-bind / / \\\n --bind {EXTERNAL-DIR} {MOUNTPOINT-IN-GIT-DIR} \\\n --dev /dev \\\n bash\n git add git commit bwrap man bwrap" }, { "answer_id": 67444687, "author": "Prakhar de Anand", "author_id": 15642486, "author_profile": "https://Stackoverflow.com/users/15642486", "pm_score": 1, "selected": false, "text": "ln file1 file2" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15368/" ]
86,408
<p>Let's say I have an aspx page with this calendar control:</p> <pre><code>&lt;asp:Calendar ID="Calendar1" runat="server" SelectedDate="" &gt;&lt;/asp:Calendar&gt; </code></pre> <p>Is there anything I can put in for SelectedDate to make it use the current date by default, without having to use the code-behind?</p>
[ { "answer_id": 86543, "author": "Philip Rieck", "author_id": 12643, "author_profile": "https://Stackoverflow.com/users/12643", "pm_score": 5, "selected": true, "text": "<asp:Calendar ID=\"Calendar1\" runat=\"server\" SelectedDate=\"<%# DateTime.Today %>\" />\n" }, { "answer_id": 165698, "author": "Pascal Paradis", "author_id": 1291, "author_profile": "https://Stackoverflow.com/users/1291", "pm_score": 3, "selected": false, "text": "<asp:Calendar ID=\"planning\" runat=\"server\" SelectedDate=\"<%# DateTime.Now %>\"></asp:Calendar>\n protected void Page_Load(object sender, EventArgs e)\n{\n BindCalendar();\n}\n\nprivate void BindCalendar()\n{\n planning.SelectedDate = DateTime.Today;\n}\n" }, { "answer_id": 6856206, "author": "Samer Makary", "author_id": 720343, "author_profile": "https://Stackoverflow.com/users/720343", "pm_score": 3, "selected": false, "text": "protected void Page_Load(object sender, EventArgs e)\n Calendar1.SelectedDate = DateTime.Today;\n}\n protected void Page_Load(object sender, EventArgs e)\n{\n DateTime today = DateTime.Today;\n Calendar1.TodaysDate = today;\n Calendar1.SelectedDate = Calendar1.TodaysDate;\n}\n" }, { "answer_id": 7047257, "author": "gaz", "author_id": 892575, "author_profile": "https://Stackoverflow.com/users/892575", "pm_score": 0, "selected": false, "text": "<asp:Calendar ID=\"calDateFrom\" SelectedDate=\"08/02/2011\" SelectionMode=\"Day\" runat=\"server\"></asp:Calendar>\n<asp:Calendar runat=\"server\" SelectionMode=\"Day\" SelectedDate=\"08/15/2011 12:00:00 AM\" ID=\"Calendar1\" VisibleDate=\"08/03/2011 12:00:00 AM\"></asp:Calendar>\n<asp:Calendar SelectionMode=\"Day\" SelectedDate=\"08/31/2011 12:00:00 AM\" runat=\"server\" ID=\"calDateTo\"></asp:Calendar>\n" }, { "answer_id": 8422671, "author": "David.Chu.ca", "author_id": 62776, "author_profile": "https://Stackoverflow.com/users/62776", "pm_score": 0, "selected": false, "text": "protected void Page_Load(object sender, EventArgs e)\n{\n if (!Page.IsPostBack)\n {\n DateTime dt = DateTime.Now.AddDays(-1);\n Calendar1.VisibleDate = dt;\n Calendar1.SelectedDate = dt;\n Calendar1.TodaysDate = dt;\n ...\n }\n }\n" }, { "answer_id": 11358480, "author": "user1235809", "author_id": 1235809, "author_profile": "https://Stackoverflow.com/users/1235809", "pm_score": 2, "selected": false, "text": "dtpStartDate.SelectedDate = Convert.ToDateTime(DateTime.Now.Date);\ndtpStartDate.VisibleDate = Convert.ToDateTime(DateTime.Now.ToString());\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
86,413
<p>What is the best way to create a fixed width file in C#. I have a bunch of fields with lengths to write out. Say 20,80.10,2 etc all left aligned. Is there an easy way to do this? </p>
[ { "answer_id": 86462, "author": "Andrew Burgess", "author_id": 12096, "author_profile": "https://Stackoverflow.com/users/12096", "pm_score": 3, "selected": false, "text": "handle.WriteLine(s20.PadRight(20));\nhandle.WriteLine(s80.PadRight(80));\nhandle.WriteLine(s10.PadRight(10));\nhandle.WriteLine(s2.PadRight(2));\n" }, { "answer_id": 86483, "author": "Wheelie", "author_id": 1131, "author_profile": "https://Stackoverflow.com/users/1131", "pm_score": 7, "selected": true, "text": "string a = String.Format(\"|{0,5}|{1,5}|{2,5}\", 1, 20, 300);\nstring b = String.Format(\"|{0,-5}|{1,-5}|{2,-5}\", 1, 20, 300);\n\n// 'a' will be equal to \"| 1| 20| 300|\"\n// 'b' will be equal to \"|1 |20 |300 |\"\n" }, { "answer_id": 86682, "author": "Chris Wenham", "author_id": 5548, "author_profile": "https://Stackoverflow.com/users/5548", "pm_score": 5, "selected": false, "text": "<WriteFixedWidth Table=\"orders\" StartAt=\"1\" Output=\"Return\">\n <Position Start=\"1\" Length=\"17\" Name=\"Unique Identifier\"/>\n <Position Start=\"18\" Length=\"3\" Name=\"Error Flag\"/>\n <Position Start=\"21\" Length=\"16\" Name=\"Account Number\" Justification=\"right\"/>\n <Position Start=\"37\" Length=\"8\" Name=\"Member Number\"/>\n <Position Start=\"45\" Length=\"4\" Name=\"Product\"/>\n <Position Start=\"49\" Length=\"3\" Name=\"Paytype\"/>\n <Position Start=\"52\" Length=\"9\" Name=\"Transit Routing Number\"/>\n</WriteFixedWidth>\n XDocument.Load(filename) .Descendants(\"WriteFixedWidth\") XDocument public void WriteFixedWidth(System.Xml.Linq.XElement CommandNode, DataTable Table, Stream outputStream)\n {\n StreamWriter Output = new StreamWriter(outputStream);\n int StartAt = CommandNode.Attribute(\"StartAt\") != null ? int.Parse(CommandNode.Attribute(\"StartAt\").Value) : 0;\n\n var positions = from c in CommandNode.Descendants(Namespaces.Integration + \"Position\")\n orderby int.Parse(c.Attribute(\"Start\").Value) ascending\n select new\n {\n Name = c.Attribute(\"Name\").Value,\n Start = int.Parse(c.Attribute(\"Start\").Value) - StartAt,\n Length = int.Parse(c.Attribute(\"Length\").Value),\n Justification = c.Attribute(\"Justification\") != null ? c.Attribute(\"Justification\").Value.ToLower() : \"left\"\n };\n\n int lineLength = positions.Last().Start + positions.Last().Length;\n foreach (DataRow row in Table.Rows)\n {\n StringBuilder line = new StringBuilder(lineLength);\n foreach (var p in positions)\n line.Insert(p.Start, \n p.Justification == \"left\" ? (row.Field<string>(p.Name) ?? \"\").PadRight(p.Length,' ')\n : (row.Field<string>(p.Name) ?? \"\").PadLeft(p.Length,' ') \n );\n Output.WriteLine(line.ToString());\n }\n Output.Flush();\n }\n" }, { "answer_id": 11009564, "author": "Darren", "author_id": 329367, "author_profile": "https://Stackoverflow.com/users/329367", "pm_score": 2, "selected": false, "text": "public static class StringExtensions\n{\n\n /// <summary>\n /// FixedWidth string extension method. Trims spaces, then pads right.\n /// </summary>\n /// <param name=\"self\">extension method target</param>\n /// <param name=\"totalLength\">The length of the string to return (including 'spaceOnRight')</param>\n /// <param name=\"spaceOnRight\">The number of spaces required to the right of the content.</param>\n /// <returns>a new string</returns>\n /// <example>\n /// This example calls the extension method 3 times to construct a string with 3 fixed width fields of 20 characters, \n /// 2 of which are reserved for empty spacing on the right side.\n /// <code>\n ///const int colWidth = 20;\n ///const int spaceRight = 2;\n ///string headerLine = string.Format(\n /// \"{0}{1}{2}\",\n /// \"Title\".FixedWidth(colWidth, spaceRight),\n /// \"Quantity\".FixedWidth(colWidth, spaceRight),\n /// \"Total\".FixedWidth(colWidth, spaceRight));\n /// </code>\n /// </example>\n public static string FixedWidth(this string self, int totalLength, int spaceOnRight)\n {\n if (totalLength < spaceOnRight) spaceOnRight = 1; // handle silly use.\n\n string s = self.Trim();\n\n if (s.Length > (totalLength - spaceOnRight))\n {\n s = s.Substring(0, totalLength - spaceOnRight);\n }\n\n return s.PadRight(totalLength);\n }\n}\n" }, { "answer_id": 29341181, "author": "Jojo", "author_id": 223704, "author_profile": "https://Stackoverflow.com/users/223704", "pm_score": 2, "selected": false, "text": "String StringBuilder public static StringBuilder AppendFixed(this StringBuilder sb, int length, string value)\n{\n if (String.IsNullOrWhiteSpace(value))\n return sb.Append(String.Empty.PadLeft(length));\n\n if (value.Length <= length)\n return sb.Append(value.PadLeft(length));\n else\n return sb.Append(value.Substring(0, length));\n}\n\npublic static StringBuilder AppendFixed(this StringBuilder sb, int length, string value, out string rest)\n{\n rest = String.Empty;\n\n if (String.IsNullOrWhiteSpace(value))\n return sb.AppendFixed(length, value);\n\n if (value.Length > length)\n rest = value.Substring(length);\n\n return sb.AppendFixed(length, value);\n}\n out string rest; \n\nStringBuilder clientRecord = new StringBuilder();\nclientRecord.AppendFixed(40, doc.ClientName, out rest); \nclientRecord.AppendFixed(40, rest);\nclientRecord.AppendFixed(40, doc.ClientAddress, out rest);\nclientRecord.AppendFixed(40, rest);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
86,417
<p>I have a custom (code-based) workflow, deployed in WSS via features in a .wsp file. The workflow is configured with a custom task content type (ie, the Workflow element contains a TaskListContentTypeId attribute). This content type's declaration contains a FormUrls element pointing to a custom task edit page.</p> <p>When the workflow attempts to create a task, the workflow throws this exception:</p> <p><code>Invalid field name. {17ca3a22-fdfe-46eb-99b5-9646baed3f16</code></p> <p>This is the ID of the FormURN site column. I thought FormURN is only used for InfoPath forms, not regular aspx forms...</p> <p>Does anyone have any idea how to solve this, so I can create tasks in my workflow?</p>
[ { "answer_id": 86462, "author": "Andrew Burgess", "author_id": 12096, "author_profile": "https://Stackoverflow.com/users/12096", "pm_score": 3, "selected": false, "text": "handle.WriteLine(s20.PadRight(20));\nhandle.WriteLine(s80.PadRight(80));\nhandle.WriteLine(s10.PadRight(10));\nhandle.WriteLine(s2.PadRight(2));\n" }, { "answer_id": 86483, "author": "Wheelie", "author_id": 1131, "author_profile": "https://Stackoverflow.com/users/1131", "pm_score": 7, "selected": true, "text": "string a = String.Format(\"|{0,5}|{1,5}|{2,5}\", 1, 20, 300);\nstring b = String.Format(\"|{0,-5}|{1,-5}|{2,-5}\", 1, 20, 300);\n\n// 'a' will be equal to \"| 1| 20| 300|\"\n// 'b' will be equal to \"|1 |20 |300 |\"\n" }, { "answer_id": 86682, "author": "Chris Wenham", "author_id": 5548, "author_profile": "https://Stackoverflow.com/users/5548", "pm_score": 5, "selected": false, "text": "<WriteFixedWidth Table=\"orders\" StartAt=\"1\" Output=\"Return\">\n <Position Start=\"1\" Length=\"17\" Name=\"Unique Identifier\"/>\n <Position Start=\"18\" Length=\"3\" Name=\"Error Flag\"/>\n <Position Start=\"21\" Length=\"16\" Name=\"Account Number\" Justification=\"right\"/>\n <Position Start=\"37\" Length=\"8\" Name=\"Member Number\"/>\n <Position Start=\"45\" Length=\"4\" Name=\"Product\"/>\n <Position Start=\"49\" Length=\"3\" Name=\"Paytype\"/>\n <Position Start=\"52\" Length=\"9\" Name=\"Transit Routing Number\"/>\n</WriteFixedWidth>\n XDocument.Load(filename) .Descendants(\"WriteFixedWidth\") XDocument public void WriteFixedWidth(System.Xml.Linq.XElement CommandNode, DataTable Table, Stream outputStream)\n {\n StreamWriter Output = new StreamWriter(outputStream);\n int StartAt = CommandNode.Attribute(\"StartAt\") != null ? int.Parse(CommandNode.Attribute(\"StartAt\").Value) : 0;\n\n var positions = from c in CommandNode.Descendants(Namespaces.Integration + \"Position\")\n orderby int.Parse(c.Attribute(\"Start\").Value) ascending\n select new\n {\n Name = c.Attribute(\"Name\").Value,\n Start = int.Parse(c.Attribute(\"Start\").Value) - StartAt,\n Length = int.Parse(c.Attribute(\"Length\").Value),\n Justification = c.Attribute(\"Justification\") != null ? c.Attribute(\"Justification\").Value.ToLower() : \"left\"\n };\n\n int lineLength = positions.Last().Start + positions.Last().Length;\n foreach (DataRow row in Table.Rows)\n {\n StringBuilder line = new StringBuilder(lineLength);\n foreach (var p in positions)\n line.Insert(p.Start, \n p.Justification == \"left\" ? (row.Field<string>(p.Name) ?? \"\").PadRight(p.Length,' ')\n : (row.Field<string>(p.Name) ?? \"\").PadLeft(p.Length,' ') \n );\n Output.WriteLine(line.ToString());\n }\n Output.Flush();\n }\n" }, { "answer_id": 11009564, "author": "Darren", "author_id": 329367, "author_profile": "https://Stackoverflow.com/users/329367", "pm_score": 2, "selected": false, "text": "public static class StringExtensions\n{\n\n /// <summary>\n /// FixedWidth string extension method. Trims spaces, then pads right.\n /// </summary>\n /// <param name=\"self\">extension method target</param>\n /// <param name=\"totalLength\">The length of the string to return (including 'spaceOnRight')</param>\n /// <param name=\"spaceOnRight\">The number of spaces required to the right of the content.</param>\n /// <returns>a new string</returns>\n /// <example>\n /// This example calls the extension method 3 times to construct a string with 3 fixed width fields of 20 characters, \n /// 2 of which are reserved for empty spacing on the right side.\n /// <code>\n ///const int colWidth = 20;\n ///const int spaceRight = 2;\n ///string headerLine = string.Format(\n /// \"{0}{1}{2}\",\n /// \"Title\".FixedWidth(colWidth, spaceRight),\n /// \"Quantity\".FixedWidth(colWidth, spaceRight),\n /// \"Total\".FixedWidth(colWidth, spaceRight));\n /// </code>\n /// </example>\n public static string FixedWidth(this string self, int totalLength, int spaceOnRight)\n {\n if (totalLength < spaceOnRight) spaceOnRight = 1; // handle silly use.\n\n string s = self.Trim();\n\n if (s.Length > (totalLength - spaceOnRight))\n {\n s = s.Substring(0, totalLength - spaceOnRight);\n }\n\n return s.PadRight(totalLength);\n }\n}\n" }, { "answer_id": 29341181, "author": "Jojo", "author_id": 223704, "author_profile": "https://Stackoverflow.com/users/223704", "pm_score": 2, "selected": false, "text": "String StringBuilder public static StringBuilder AppendFixed(this StringBuilder sb, int length, string value)\n{\n if (String.IsNullOrWhiteSpace(value))\n return sb.Append(String.Empty.PadLeft(length));\n\n if (value.Length <= length)\n return sb.Append(value.PadLeft(length));\n else\n return sb.Append(value.Substring(0, length));\n}\n\npublic static StringBuilder AppendFixed(this StringBuilder sb, int length, string value, out string rest)\n{\n rest = String.Empty;\n\n if (String.IsNullOrWhiteSpace(value))\n return sb.AppendFixed(length, value);\n\n if (value.Length > length)\n rest = value.Substring(length);\n\n return sb.AppendFixed(length, value);\n}\n out string rest; \n\nStringBuilder clientRecord = new StringBuilder();\nclientRecord.AppendFixed(40, doc.ClientName, out rest); \nclientRecord.AppendFixed(40, rest);\nclientRecord.AppendFixed(40, doc.ClientAddress, out rest);\nclientRecord.AppendFixed(40, rest);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5782/" ]
86,428
<p>I would like to reload an <code>&lt;iframe&gt;</code> using JavaScript. The best way I found until now was set the iframe’s <code>src</code> attribute to itself, but this isn’t very clean. Any ideas?</p>
[ { "answer_id": 86441, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 4, "selected": false, "text": "window.frames['frameNameOrIndex'].location.reload();\n" }, { "answer_id": 86771, "author": "Ed.", "author_id": 12257, "author_profile": "https://Stackoverflow.com/users/12257", "pm_score": 9, "selected": true, "text": "document.getElementById('some_frame_id').contentWindow.location.reload();\n window.frames[]" }, { "answer_id": 2175738, "author": "Shaulian", "author_id": 247929, "author_profile": "https://Stackoverflow.com/users/247929", "pm_score": 2, "selected": false, "text": "iframe.src iframe.src page_load iframe.contentDocument.location.href = \"NewUrl.htm\"" }, { "answer_id": 4062084, "author": "evko", "author_id": 492602, "author_profile": "https://Stackoverflow.com/users/492602", "pm_score": 8, "selected": false, "text": "document.getElementById('iframeid').src = document.getElementById('iframeid').src\n iframe http://example.com/#something" }, { "answer_id": 7809798, "author": "lousygarua", "author_id": 1001477, "author_profile": "https://Stackoverflow.com/users/1001477", "pm_score": 6, "selected": false, "text": "$('#your_iframe').attr('src', $('#your_iframe').attr('src'));\n" }, { "answer_id": 8304685, "author": "yajra", "author_id": 1070424, "author_profile": "https://Stackoverflow.com/users/1070424", "pm_score": 2, "selected": false, "text": "if(navigator.appName == \"Microsoft Internet Explorer\"){\n window.document.getElementById('iframeId').contentWindow.location.reload(true);\n}else {\n window.document.getElementById('iframeId').src = window.document.getElementById('iframeId').src;\n}\n" }, { "answer_id": 10708440, "author": "Sid", "author_id": 1411029, "author_profile": "https://Stackoverflow.com/users/1411029", "pm_score": 1, "selected": false, "text": "<script type=\"text/javascript\">\n top.frames['DetailFrame'].location = top.frames['DetailFrame'].location;\n</script> \n" }, { "answer_id": 11763299, "author": "Liam M", "author_id": 1021915, "author_profile": "https://Stackoverflow.com/users/1021915", "pm_score": 3, "selected": false, "text": "$(\".iframe_wrapper\").find(\"iframe\").remove();\nvar iframe = $('<iframe src=\"' + src + '\" frameborder=\"0\"></iframe>');\n$.find(\".iframe_wrapper\").append(iframe);\n" }, { "answer_id": 12435272, "author": "Aaron Wallentine", "author_id": 1593026, "author_profile": "https://Stackoverflow.com/users/1593026", "pm_score": 2, "selected": false, "text": "function reload_message_frame() {\n var frame_id = 'live_message_frame';\n if(window.document.getElementById(frame_id).location ) { \n window.document.getElementById(frame_id).location.reload(true);\n } else if (window.document.getElementById(frame_id).contentWindow.location ) {\n window.document.getElementById(frame_id).contentWindow.location.reload(true);\n } else if (window.document.getElementById(frame_id).src){\n window.document.getElementById(frame_id).src = window.document.getElementById(frame_id).src;\n } else {\n // fail condition, respond as appropriate, or do nothing\n alert(\"Sorry, unable to reload that frame!\");\n }\n}\n" }, { "answer_id": 17808455, "author": "Marcin Janeczek", "author_id": 2011042, "author_profile": "https://Stackoverflow.com/users/2011042", "pm_score": 1, "selected": false, "text": "window.location.reload();\n" }, { "answer_id": 21413778, "author": "user2675617", "author_id": 2675617, "author_profile": "https://Stackoverflow.com/users/2675617", "pm_score": 2, "selected": false, "text": "location.assign(\"http:google.com\");\n location.reload();\n" }, { "answer_id": 21638602, "author": "user1212212", "author_id": 1212212, "author_profile": "https://Stackoverflow.com/users/1212212", "pm_score": 1, "selected": false, "text": "<iframe src=\"myBaseURL.com/something/\" />\n\n<script>\nvar i = document.getElementsById(\"iframe\")[0],\n src = i.src,\n number = 1;\n\n//For an update\ni.src = src + \"?ignoreMe=\" + number;\nnumber++;\n</script>\n" }, { "answer_id": 22849931, "author": "Todd", "author_id": 1817127, "author_profile": "https://Stackoverflow.com/users/1817127", "pm_score": 0, "selected": false, "text": "<a class=\"refresh-this-frame\" rel=\"#iframe-id-0\">Refresh</a>\n<iframe src=\"\" id=\"iframe-id-0\"></iframe>\n $('.refresh-this-frame').click(function() {\n var thisIframe = $(this).attr('rel');\n var currentState = $(thisIframe).attr('src');\n function removeSrc() {\n $(thisIframe).attr('src', '');\n }\n setTimeout (removeSrc, 100);\n function replaceSrc() {\n $(thisIframe).attr('src', currentState);\n }\n setTimeout (replaceSrc, 200);\n});\n $('.refresh-this-frame').click(function() {\n var targetID = $(this).attr('rel');\n var targetSrc = $(targetID).attr('src');\n var cleanID = targetID.replace(\"#\",\"\"); \n var chromeTest = ( navigator.userAgent.match(/Chrome/g) ? true : false );\n var FFTest = ( navigator.userAgent.match(/Firefox/g) ? true : false ); \n if (chromeTest == true) {\n function removeSrc() {\n $(targetID).attr('src', '');\n }\n setTimeout (removeSrc, 100);\n function replaceSrc() {\n $(targetID).attr('src', targetSrc);\n }\n setTimeout (replaceSrc, 200);\n }\n if (FFTest == true) {\n function removeSrc() {\n $(targetID).attr('src', '');\n }\n setTimeout (removeSrc, 100);\n function replaceSrc() {\n $(targetID).attr('src', targetSrc);\n }\n setTimeout (replaceSrc, 200);\n } \n if (chromeTest == false && FFTest == false) {\n var targetLoc = (document.getElementById(cleanID).contentWindow.location).toString();\n function removeSrc() {\n $(targetID).attr('src', '');\n }\n setTimeout (removeSrc, 100);\n function replaceSrc2() {\n $(targetID).attr('src', targetLoc);\n }\n setTimeout (replaceSrc2, 200);\n }\n});\n" }, { "answer_id": 23558286, "author": "Paresh3489227", "author_id": 3489227, "author_profile": "https://Stackoverflow.com/users/3489227", "pm_score": 2, "selected": false, "text": "$('#iframeID',window.parent.document).attr('src',$('#iframeID',window.parent.document).attr('src'));\n $('#iframeID',parent.document).attr('src',$('#iframeID',parent.document).attr('src'));\n" }, { "answer_id": 32740941, "author": "Patrick Rudolph", "author_id": 1024108, "author_profile": "https://Stackoverflow.com/users/1024108", "pm_score": 3, "selected": false, "text": "src var url = iframeEl.src;\niframeEl.src = 'about:blank';\nsetTimeout(function() {\n iframeEl.src = url;\n}, 10);\n" }, { "answer_id": 43716241, "author": "Vivek Kumar", "author_id": 5163085, "author_profile": "https://Stackoverflow.com/users/5163085", "pm_score": 2, "selected": false, "text": "self.location.reload() <iframe src=\"https://vivekkumar11432.wordpress.com/\" width=\"300\" height=\"300\"></iframe>\n<br><br>\n<input type='button' value=\"Reload\" onclick=\"self.location.reload();\" />" }, { "answer_id": 46199589, "author": "h3dkandi", "author_id": 2870783, "author_profile": "https://Stackoverflow.com/users/2870783", "pm_score": 0, "selected": false, "text": "document.location.reload()" }, { "answer_id": 46902311, "author": "Yohanim", "author_id": 1533670, "author_profile": "https://Stackoverflow.com/users/1533670", "pm_score": 5, "selected": false, "text": "src document.getElementById('id').src += '';\n" }, { "answer_id": 48139507, "author": "Vasile Alexandru Peşte", "author_id": 6419448, "author_profile": "https://Stackoverflow.com/users/6419448", "pm_score": 2, "selected": false, "text": "const frame = document.getElementById(\"my-iframe\");\n\nframe.parentNode.replaceChild(frame.cloneNode(), frame);\n" }, { "answer_id": 50511220, "author": "Northern", "author_id": 3496582, "author_profile": "https://Stackoverflow.com/users/3496582", "pm_score": 2, "selected": false, "text": "const reloadIframe = (iframeId) => {\n const el = document.getElementById(iframeId)\n const src = el.src\n el.src = ''\n setTimeout(() => {\n el.src = src\n })\n}\n" }, { "answer_id": 69028065, "author": "Andrii Verbytskyi", "author_id": 2768917, "author_profile": "https://Stackoverflow.com/users/2768917", "pm_score": 1, "selected": false, "text": "document.location.href = document.location.href\n" }, { "answer_id": 73116824, "author": "Reed Thorngag", "author_id": 15233212, "author_profile": "https://Stackoverflow.com/users/15233212", "pm_score": 0, "selected": false, "text": "function reload() {\n document.getElementById('iframe').src = '';\n document.getElementById('iframe').src = url;\n}\n function setBack() {\n document.getElementById('iframe').src = url;\n}\nfunction reload() {\n document.getElementById('iframe').src = '';\n setTimeout(setBack,100);\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8276/" ]
86,435
<p>I'm receiving feedback from a developer that "The only way visual basic (6) can deal with a UNC path is to map it to a drive." Is this accurate? And, if so, what's the underlying issue and are there any alternatives other than a mapped drive?</p>
[ { "answer_id": 86482, "author": "Darrel Miller", "author_id": 6819, "author_profile": "https://Stackoverflow.com/users/6819", "pm_score": 3, "selected": true, "text": "Sub Main()\n\n Dim fs As New FileSystemObject ' Add Reference to Microsoft Scripting Runtime\n MsgBox fs.FileExists(\"\\\\server\\folder\\file.ext\")\n\nEnd Sub\n" }, { "answer_id": 86568, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://Stackoverflow.com/users/2260", "pm_score": 1, "selected": false, "text": "Scripting.Runtime" }, { "answer_id": 101291, "author": "dummy", "author_id": 6297, "author_profile": "https://Stackoverflow.com/users/6297", "pm_score": 2, "selected": false, "text": "Open \"\\\\host\\share\\file.txt\" For Input As #1\nDim sTmp\nLine Input #1, sTmp\nMsgBox sTmp\nClose #1\n" }, { "answer_id": 20334434, "author": "finch", "author_id": 1258623, "author_profile": "https://Stackoverflow.com/users/1258623", "pm_score": 1, "selected": false, "text": "ChDrive App.Path" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5199/" ]
86,458
<p>Does a free .NET library exist with which I can upload a file to a SFTP (SSH FTP) server, which throws exceptions on problems with the upload and allows the monitoring of its progress?</p>
[ { "answer_id": 3057802, "author": "Martin Vobr", "author_id": 16132, "author_profile": "https://Stackoverflow.com/users/16132", "pm_score": 3, "selected": false, "text": "// create client, connect and log in \nSftp client = new Sftp();\nclient.Connect(hostname);\nclient.Login(username, password);\n\n// upload the 'test.zip' file to the current directory at the server \nclient.PutFile(@\"c:\\data\\test.zip\", \"test.zip\");\n\nclient.Disconnect();\n client.LogWriter = new Rebex.FileLogWriter(\n @\"c:\\temp\\log.txt\", Rebex.LogLevel.Debug); \n Sftp client = new Sftp();\nclient.CommandSent += new SftpCommandSentEventHandler(client_CommandSent);\nclient.ResponseRead += new SftpResponseReadEventHandler(client_ResponseRead);\nclient.Connect(\"sftp.example.org\");\n\n//... \nprivate void client_CommandSent(object sender, SftpCommandSentEventArgs e)\n{\n Console.WriteLine(\"Command: {0}\", e.Command);\n}\n\nprivate void client_ResponseRead(object sender, SftpResponseReadEventArgs e)\n{\n Console.WriteLine(\"Response: {0}\", e.Response);\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1595/" ]
86,477
<p>In JavaScript:</p> <pre><code>encodeURIComponent("©√") == "%C2%A9%E2%88%9A" </code></pre> <p>Is there an equivalent for C# applications? For escaping HTML characters I used:</p> <pre><code>txtOut.Text = Regex.Replace(txtIn.Text, @"[\u0080-\uFFFF]", m =&gt; @"&amp;#" + ((int)m.Value[0]).ToString() + ";"); </code></pre> <p>But I'm not sure how to convert the match to the correct hexadecimal format that JS uses. For example this code:</p> <pre><code>txtOut.Text = Regex.Replace(txtIn.Text, @"[\u0080-\uFFFF]", m =&gt; @"%" + String.Format("{0:x}", ((int)m.Value[0]))); </code></pre> <p>Returns "<code>%a9%221a"</code> for <code>"©√"</code> instead of <code>"%C2%A9%E2%88%9A"</code>. It looks like I need to split the string up into bytes or something.</p> <p>Edit: This is for a windows app, the only items available in <code>System.Web</code> are: <code>AspNetHostingPermission</code>, <code>AspNetHostingPermissionAttribute</code>, and <code>AspNetHostingPermissionLevel</code>.</p>
[ { "answer_id": 86484, "author": "David Thibault", "author_id": 5903, "author_profile": "https://Stackoverflow.com/users/5903", "pm_score": 4, "selected": false, "text": "HttpUtility.HtmlEncode HttpUtility.UrlEncode System.Web" }, { "answer_id": 86492, "author": "Billy Jo", "author_id": 3447, "author_profile": "https://Stackoverflow.com/users/3447", "pm_score": 3, "selected": false, "text": "Server.UrlEncode() System.Web.HttpUtility.UrlEncode() Server System.Uri.EscapeUriString() System.Web" }, { "answer_id": 4550600, "author": "Steve", "author_id": 355583, "author_profile": "https://Stackoverflow.com/users/355583", "pm_score": 9, "selected": true, "text": "Uri.EscapeDataString HttpUtility.UrlEncode \"Stack Overflow\" HttpUtility.UrlEncode(\"Stack Overflow\") \"Stack+Overflow\" Uri.EscapeUriString(\"Stack Overflow\") \"Stack%20Overflow\" Uri.EscapeDataString(\"Stack + Overflow\") \"+\" to \"%2b\" Stack%20%2B%20%20Overflow" }, { "answer_id": 4902681, "author": "Ali Mamedov", "author_id": 603774, "author_profile": "https://Stackoverflow.com/users/603774", "pm_score": 4, "selected": false, "text": "string a = \"!@#$%^&*()_+ some text here али мамедов баку\";\na = System.Web.HttpUtility.UrlEncode(a);\na = a.Replace(\"+\", \"%20\");\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1414/" ]
86,491
<p>ASP.NET 2.0 provides the <code>ClientScript.RegisterClientScriptBlock()</code> method for registering JavaScript in an ASP.NET Page.</p> <p>The issue I'm having is passing the script when it's located in another directory. Specifically, the following syntax does not work:</p> <pre><code>ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", "../dir/subdir/scriptName.js", true); </code></pre> <p>Instead of dropping the code into the page like <a href="http://msdn.microsoft.com/en-us/library/aa479390.aspx#javawasp2_topic7" rel="nofollow noreferrer">this page</a> says it should, it instead displays <code>../dir/subdir/script.js</code> , my question is this:</p> <p>Has anyone dealt with this before, and found a way to drop in the javascript in a separate file? Am I going about this the wrong way?</p>
[ { "answer_id": 86496, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": -1, "selected": false, "text": "<script type='text/javascript' src='yourpathhere'></script>\n" }, { "answer_id": 86523, "author": "Nick Craver", "author_id": 13249, "author_profile": "https://Stackoverflow.com/users/13249", "pm_score": 4, "selected": true, "text": "ClientScript.RegisterClientScriptInclude(this.GetType(), \"scriptName\", \"../dir/subdir/scriptName.js\")\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16587/" ]
86,513
<p>The eval function is a powerful and easy way to dynamically generate code, so what are the caveats?</p>
[ { "answer_id": 86530, "author": "Brian", "author_id": 15901, "author_profile": "https://Stackoverflow.com/users/15901", "pm_score": 4, "selected": false, "text": "goto" }, { "answer_id": 87099, "author": "MarkR", "author_id": 13724, "author_profile": "https://Stackoverflow.com/users/13724", "pm_score": 3, "selected": false, "text": "eval() eval()" }, { "answer_id": 87260, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 8, "selected": false, "text": "eval('document.' + potato + '.style.color = \"red\"');\n document[potato].style.color = 'red';\n document.getElementById(potato).style.color = 'red';\n" }, { "answer_id": 87809, "author": "matt lohkamp", "author_id": 14026, "author_profile": "https://Stackoverflow.com/users/14026", "pm_score": 4, "selected": false, "text": "eval('al' + 'er' + 't(\\'' + 'hi there!' + '\\')');\n" }, { "answer_id": 2409696, "author": "Ian", "author_id": 289724, "author_profile": "https://Stackoverflow.com/users/289724", "pm_score": 2, "selected": false, "text": "eval(uate) string1 === string2" }, { "answer_id": 28485325, "author": "Carnix", "author_id": 1553283, "author_profile": "https://Stackoverflow.com/users/1553283", "pm_score": 1, "selected": false, "text": "//Place this in a common/global JS lib:\nvar NS = function(namespace){\n var namespaceParts = String(namespace).split(\".\");\n var namespaceToTest = \"\";\n for(var i = 0; i < namespaceParts.length; i++){\n if(i === 0){\n namespaceToTest = namespaceParts[i];\n }\n else{\n namespaceToTest = namespaceToTest + \".\" + namespaceParts[i];\n }\n\n if(eval('typeof ' + namespaceToTest) === \"undefined\"){\n eval(namespaceToTest + ' = {}');\n }\n }\n return eval(namespace);\n}\n\n\n//Then, use this in your class definition libs:\nNS('Root.Namespace').Class = function(settings){\n //Class constructor code here\n}\n//some generic method:\nRoot.Namespace.Class.prototype.Method = function(args){\n //Code goes here\n //this.MyOtherMethod(\"foo\")); // => \"foo\"\n return true;\n}\n\n\n//Then, in your applications, use this to instantiate an instance of your class:\nvar anInstanceOfClass = new Root.Namespace.Class(settings);\n" }, { "answer_id": 40842765, "author": "Wikened", "author_id": 5678694, "author_profile": "https://Stackoverflow.com/users/5678694", "pm_score": 2, "selected": false, "text": "eval() eval() <div>\n {{#each names}}\n <span>{{this}}</span>\n {{/each}}\n</div>\n (function (state) {\n var Runtime = Hyperbars.Runtime;\n var context = state;\n return h('div', {}, [Runtime.each(context['names'], context, function (context, parent, options) {\n return [h('span', {}, [options['@index'], context])]\n })])\n}.bind({}))\n eval()" }, { "answer_id": 43849817, "author": "12345678", "author_id": 7898897, "author_profile": "https://Stackoverflow.com/users/7898897", "pm_score": 2, "selected": false, "text": "// antipattern\nvar property = \"name\";\nalert(eval(\"obj.\" + property));\n\n// preferred\nvar property = \"name\";\nalert(obj[property]);\n eval() JSON.parse() setInterval() setTimeout() Function() eval() // antipatterns\nsetTimeout(\"myFunc()\", 1000);\nsetTimeout(\"myFunc(1, 2, 3)\", 1000);\n\n// preferred\nsetTimeout(myFunc, 1000);\nsetTimeout(function () {\nmyFunc(1, 2, 3);\n}, 1000);\n eval() eval()" }, { "answer_id": 49048785, "author": "Adam Copley", "author_id": 5579365, "author_profile": "https://Stackoverflow.com/users/5579365", "pm_score": 2, "selected": false, "text": "eval() eval()" }, { "answer_id": 57471151, "author": "J D", "author_id": 806041, "author_profile": "https://Stackoverflow.com/users/806041", "pm_score": 2, "selected": false, "text": "document.getElementById(\"evalLeak\").onclick = (e) => {\n for(let x = 0; x < 100; x++) {\n eval(x.toString());\n }\n};\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5471/" ]
86,515
<p>I'm using CVS on Windows (with the WinCVS front end), and would like to add details of the last check in to the email from our automated build process, whenever a build fails, in order to make it easier to fix.</p> <p>I need to know the files that have changed, the user that changed them, and the comment.</p> <p>I've been trying to work out the command line options, but never seem to get accurate results (either get too many result rather than just from one checkin, or details of some random check in from two weeks ago)</p>
[ { "answer_id": 86605, "author": "Rob Wells", "author_id": 2974, "author_profile": "https://Stackoverflow.com/users/2974", "pm_score": 2, "selected": true, "text": "cvs history -c -a -D \"7 days ago\" |\n gawk '{ print \"$1 == \\\"\" $6 \"\\\" && $2 == \\\"\" $8 \"/\" $7 \"\\\" { print \\\"\" $2 \" \" $3 \" \" $6 \" \" $5 \" \" $8 \"/\" $7 \"\\\"; next }\" }' > /tmp/$$.awk\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1078/" ]
86,526
<p>I have an Ant script that performs a copy operation using the <a href="http://ant.apache.org/manual/Tasks/copy.html" rel="noreferrer">'copy' task</a>. It was written for Windows, and has a hardcoded C:\ path as the 'todir' argument. I see the 'exec' task has an OS argument, is there a similar way to branch a copy based on OS?</p>
[ { "answer_id": 86593, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "build.properties" }, { "answer_id": 86597, "author": "jsight", "author_id": 1432, "author_profile": "https://Stackoverflow.com/users/1432", "pm_score": 2, "selected": false, "text": "<condition property=\"isMacOsButNotMacOsX\">\n<and>\n <os family=\"mac\"/>\n\n <not>\n <os family=\"unix\"/>\n\n </not>\n</and>\n" }, { "answer_id": 86628, "author": "benzado", "author_id": 10947, "author_profile": "https://Stackoverflow.com/users/10947", "pm_score": 6, "selected": true, "text": "<condition property=\"foo.path\" value=\"C:\\Foo\\Dir\">\n <os family=\"windows\"/>\n</condition>\n<condition property=\"foo.path\" value=\"/home/foo/dir\">\n <os family=\"unix\"/>\n</condition>\n\n<fail unless=\"foo.path\">No foo.path set for this OS!</fail>\n" }, { "answer_id": 126947, "author": "Mads Hansen", "author_id": 14419, "author_profile": "https://Stackoverflow.com/users/14419", "pm_score": 3, "selected": false, "text": "<copy todir=\"/tmp\" overwrite=\"true\" >\n <fileset dir=\"${lib.dir}\">\n <include name=\"*.jar\" />\n </fileset>\n</copy>\n <condition property=\"root.drive\" value=\"C:/\" else=\"/\">\n <os family=\"windows\" />\n </condition>\n <copy todir=\"${root.drive}tmp\" overwrite=\"true\" >\n <fileset dir=\"${lib.dir}\">\n <include name=\"*.jar\" />\n </fileset>\n </copy>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/99021/" ]
86,531
<p>Trying to keep all the presentation stuff in the xhtml on this project and I need to format some values in a selectItem tag have a BigDecimal value and need to make it look like currency. Is there anyway to apply a <code>&lt;f:convertNumber pattern="$#,##0.00"/&gt;</code> Inside a <code>&lt;f:selectItem&gt;</code> tag?</p> <p>Any way to do this or a work around that doesn't involve pushing this into the java code?</p>
[ { "answer_id": 88805, "author": "William", "author_id": 9193, "author_profile": "https://Stackoverflow.com/users/9193", "pm_score": 3, "selected": true, "text": "itemLabel ValueExpression <f:selectItem>" }, { "answer_id": 88866, "author": "Andreas Petersson", "author_id": 16542, "author_profile": "https://Stackoverflow.com/users/16542", "pm_score": 2, "selected": false, "text": "<t:commandButton/> <mytags:commandButton/>" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9193/" ]
86,534
<p>I have a .csv file that is frequently updated (about 20 to 30 times per minute). I want to insert the newly added lines to a database as soon as they are written to the file.</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx" rel="nofollow noreferrer">FileSystemWatcher</a> class listens to the file system change notifications and can raise an event whenever there is a change in a specified file. The problem is that the FileSystemWatcher cannot determine exactly which lines were added or removed (as far as I know).</p> <p>One way to read those lines is to save and compare the line count between changes and read the difference between the last and second last change. However, I am looking for a cleaner (perhaps more elegant) solution.</p>
[ { "answer_id": 86887, "author": "RichS", "author_id": 6247, "author_profile": "https://Stackoverflow.com/users/6247", "pm_score": 3, "selected": true, "text": " public void File_Changed( object source, FileSystemEventArgs e )\n {\n lock ( this )\n {\n if ( !this.bPaused )\n {\n bool bMoreData = false;\n\n // Read from current seek position to end of file\n byte[] bytesRead = new byte[this.iMaxBytes];\n FileStream fs = new FileStream( this.strFilename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );\n\n if ( 0 == this.iPreviousSeekPos )\n {\n if ( this.bReadFromStart )\n {\n if ( null != this.BeginReadStart )\n {\n this.BeginReadStart( null, null );\n }\n this.bReadingFromStart = true;\n }\n else\n {\n if ( fs.Length > this.iMaxBytes )\n {\n this.iPreviousSeekPos = fs.Length - this.iMaxBytes;\n }\n }\n }\n\n this.iPreviousSeekPos = (int)fs.Seek( this.iPreviousSeekPos, SeekOrigin.Begin );\n int iNumBytes = fs.Read( bytesRead, 0, this.iMaxBytes );\n this.iPreviousSeekPos += iNumBytes;\n\n // If we haven't read all the data, then raise another event\n if ( this.iPreviousSeekPos < fs.Length )\n {\n bMoreData = true;\n }\n\n fs.Close();\n\n string strData = this.encoding.GetString( bytesRead );\n this.MoreData( this, strData );\n\n if ( bMoreData )\n {\n File_Changed( null, null );\n }\n else\n {\n if ( this.bReadingFromStart )\n {\n this.bReadingFromStart = false;\n if ( null != this.EndReadStart )\n {\n this.EndReadStart( null, null );\n }\n }\n }\n }\n }\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4714/" ]
86,545
<p>I've seen a few fixes for allowing PNG images to have transparency in Internet Explorer 6, but I've yet to find one that also allows you to set the background position in CSS. If you use sprites, it's a deal-breaker. I've resorted to using GIF's (which are not as high quality), not using transparent images at all, or serving a completely different stylesheet to IE6. Is there a fix for IE6 that allows for PNG transparencies AND background positioning?</p>
[ { "answer_id": 86976, "author": "Ryan Grove", "author_id": 14985, "author_profile": "https://Stackoverflow.com/users/14985", "pm_score": 1, "selected": false, "text": "clip" }, { "answer_id": 479899, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 1, "selected": false, "text": "position repeat" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13281/" ]
86,550
<p>Subversion has a superb client on Windows (Tortoise, of course). Everything I've tried on Linux just - well - sucks in comparison....</p>
[ { "answer_id": 86586, "author": "HappySmileMan", "author_id": 14073, "author_profile": "https://Stackoverflow.com/users/14073", "pm_score": 5, "selected": false, "text": "svn svn co svn://site-goes-here.org/trunk add remove move commit copy update svn help" }, { "answer_id": 86954, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 1, "selected": false, "text": "sudo apt-get install svn-workbench\n" }, { "answer_id": 3847360, "author": "Kriss", "author_id": 427181, "author_profile": "https://Stackoverflow.com/users/427181", "pm_score": 2, "selected": false, "text": ".deb nautilus -q\n" }, { "answer_id": 8830877, "author": "MGK", "author_id": 196579, "author_profile": "https://Stackoverflow.com/users/196579", "pm_score": 1, "selected": false, "text": "sudo apt-get install nautilus-script-collection-svn\n\ncp -r /usr/share/nautilus-scripts/Subversion ~/.gnome2/nautilus-scripts/\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
86,558
<p>What do you think is the best way to create SEO friendly URLs (dynamically) in Rails?</p>
[ { "answer_id": 86589, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 4, "selected": true, "text": "to_param" }, { "answer_id": 89552, "author": "Patrick McKenzie", "author_id": 15046, "author_profile": "https://Stackoverflow.com/users/15046", "pm_score": 2, "selected": false, "text": "to_param" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15846/" ]
86,561
<p>Is there any difference to the following code:</p> <pre><code>class Foo { inline int SomeFunc() { return 42; } int AnotherFunc() { return 42; } }; </code></pre> <p>Will both functions gets inlined? Does inline actually make any difference? Are there any rules on when you should or shouldn't inline code? I often use the <code>AnotherFunc</code> syntax (accessors for example) but I rarely specify <code>inline</code> directly.</p>
[ { "answer_id": 86581, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": false, "text": "inline inline" }, { "answer_id": 87602, "author": "unwieldy", "author_id": 14963, "author_profile": "https://Stackoverflow.com/users/14963", "pm_score": 2, "selected": false, "text": "class Foo \n{\n inline int SomeFunc() { return 42; }\n int AnotherFunc() { return 42; }\n};\n" }, { "answer_id": 87933, "author": "Roger Nelson", "author_id": 14964, "author_profile": "https://Stackoverflow.com/users/14964", "pm_score": 1, "selected": false, "text": "int AnotherFunc() { return 42; }\n" }, { "answer_id": 89162, "author": "Tim James", "author_id": 17055, "author_profile": "https://Stackoverflow.com/users/17055", "pm_score": 0, "selected": false, "text": "inline" }, { "answer_id": 90142, "author": "RomanM", "author_id": 14587, "author_profile": "https://Stackoverflow.com/users/14587", "pm_score": 0, "selected": false, "text": "inline" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
86,563
<p>I'm creating a custom drop down list with AJAX dropdownextender. Inside my drop panel I have linkbuttons for my options.</p> <pre><code>&lt;asp:Label ID="ddl_Remit" runat="server" Text="Select remit address." Style="display: block; width: 300px; padding:2px; padding-right: 50px; font-family: Tahoma; font-size: 11px;" /&gt; &lt;asp:Panel ID="DropPanel" runat="server" CssClass="ContextMenuPanel" Style="display :none; visibility: hidden;"&gt; &lt;asp:LinkButton runat="server" ID="Option1z" Text="451 Stinky Place Drive &lt;br/&gt;North Nowhere, Nebraska 20503-2343 " OnClick="OnSelect" CssClass="ContextMenuItem" /&gt; &lt;asp:LinkButton runat="server" ID="Option2z" Text="451 Stinky Place Drive &lt;br/&gt;North Nowhere, Nebraska 20503-2343 " OnClick="OnSelect" CssClass="ContextMenuItem" /&gt; &lt;asp:LinkButton runat="server" ID="Option3z" Text="451 Stinky Place Drive &lt;br/&gt;North Nowhere, Nebraska 20503-2343 " OnClick="OnSelect" CssClass="ContextMenuItem" /&gt;--&gt; &lt;/asp:Panel&gt; &lt;ajaxToolkit:DropDownExtender runat="server" ID="DDE" TargetControlID="ddl_Remit" DropDownControlID="DropPanel" /&gt; </code></pre> <p>And this works well. Now what I have to do is dynamically fill this dropdownlist. Here is my best attempt:</p> <pre><code>private void fillRemitDDL() { //LinkButton Text="451 Stinky Place Drive &lt;br/&gt;North Nowhere, Nebraska 20503-2343 " OnClick="OnSelect" CssClass="ContextMenuItem" DAL_ScanlineTableAdapters.SL_GetRemitByScanlineIDTableAdapter ta = new DAL_ScanlineTableAdapters.SL_GetRemitByScanlineIDTableAdapter(); DataTable dt = (DataTable)ta.GetData(int.Parse(this.SLID)); if (dt.Rows.Count &gt; 0) { Panel ddl = this.FindControl("DropPanel") as Panel; ddl.Controls.Clear(); for (int x = 0; x &lt; dt.Rows.Count; x++) { LinkButton lb = new LinkButton(); lb.Text = dt.Rows[x]["Remit3"].ToString().Trim() + "&lt;br /&gt;" + dt.Rows[x]["Remit4"].ToString().Trim() + "&lt;br /&gt;" + dt.Rows[x]["RemitZip"].ToString().Trim(); lb.CssClass = "ContextMenuItem"; lb.Attributes.Add("onclick", "setDDL(" + lb.Text + ")"); ddl.Controls.Add(lb); } } } </code></pre> <p>My problem is that I cannot get the event to run script! I've tried the above code as well as replacing </p> <pre><code>lb.Attributes.Add("onclick", "setDDL(" + lb.Text + ")"); </code></pre> <p>with</p> <pre><code>lb.Click += new EventHandler(OnSelect); </code></pre> <p>and also </p> <pre><code>lb.OnClientClick = "setDDL(" + lb.Text + ")"); </code></pre> <p>I'm testing the the branches with Alerts on client-side and getting nothing.</p> <p>Edit: I would like to try adding the generic anchor but I think I can add the element to an asp.net control. Nor can I access a client-side div from server code to add it that way. I'm going to have to use some sort of control with an event. My setDLL function goes as follows:</p> <pre><code>function setDDL(var) { alert(var); document.getElementById('ctl00_ContentPlaceHolder1_Scanline1_ddl_Remit').innerText = var; } </code></pre> <p>Also I just took out the string variable in the function call (i.e. from </p> <pre><code>lb.Attributes.Add("onclick", "setDDL(" + lb.Text + ")"); </code></pre> <p>to </p> <pre><code>lb.Attributes.Add("onclick", "setDDL()"); </code></pre>
[ { "answer_id": 87045, "author": "pinkeerach", "author_id": 16104, "author_profile": "https://Stackoverflow.com/users/16104", "pm_score": 0, "selected": false, "text": "lb.Attributes.Add(\"onclick\", \"setDDL('\" + lb.Text + \"');\");\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1491425/" ]
86,570
<p>I'm thinking about making a simple map control in WPF, and am thinking about the design of the basic map interface and am wondering if anyone has some good advice for this. </p> <p>What I'm thinking of is using a ScrollViewer (sans scroll bars) as my "view port" and then stacking everything up on top of a canvas. From Z-Index=0 up, I'm thinking:</p> <ol> <li>Base canvas for lat/long calculations, control positioning, Z-Index stacking.</li> <li>Multiple Grid elements to represent the maps at different zoom levels. Using a grid to make tiling easier.</li> <li>Map objects with positional data.</li> <li>Map controls (zoom slider, overview, etc).</li> <li>Scroll viewer with mouse move events for panning and zooming.</li> </ol> <p>Any comments suggestions on how I should be building this?</p>
[ { "answer_id": 58973320, "author": "abhijithkp", "author_id": 8498276, "author_profile": "https://Stackoverflow.com/users/8498276", "pm_score": 1, "selected": false, "text": "<Window x:Class=\"WPFTestApplication.InsertPushpin\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" \n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n xmlns:m=\"clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF\"\n Width=\"1024\" Height=\"768\">\n <Grid x:Name=\"LayoutRoot\" Background=\"White\">\n <m:Map CredentialsProvider=\"INSERT_YOUR_BING_MAPS_KEY\" \n Center=\"47.620574,-122.34942\" ZoomLevel=\"12\">\n <m:Pushpin Location=\"47.620574,-122.34942\"/>\n </m:Map>\n </Grid>\n</Window>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4580/" ]
86,582
<p>Edit: From another question I provided an answer that has links to a lot of questions/answers about singletons: <a href="https://stackoverflow.com/questions/1008019/c-singleton-design-pattern/1008289#1008289">More info about singletons here:</a></p> <p>So I have read the thread <a href="https://stackoverflow.com/questions/11831/singletons-good-design-or-a-crutch">Singletons: good design or a crutch?</a><br> And the argument still rages.</p> <p>I see Singletons as a Design Pattern (good and bad).<br><br> The problem with Singleton is not the Pattern but rather the users (sorry everybody). Everybody and their father thinks they can implement one correctly (and from the many interviews I have done, most people can't). Also because everybody thinks they can implement a correct Singleton they abuse the Pattern and use it in situations that are not appropriate (replacing global variables with Singletons!).</p> <p>So the main questions that need to be answered are:</p> <ul> <li>When should you use a Singleton</li> <li>How do you implement a Singleton correctly</li> </ul> <p>My hope for this article is that we can collect together in a single place (rather than having to google and search multiple sites) an authoritative source of when (and then how) to use a Singleton correctly. Also appropriate would be a list of Anti-Usages and common bad implementations explaining why they fail to work and for good implementations their weaknesses.<br><br><hr></p> <p>So get the ball rolling:<br> I will hold my hand up and say this is what I use but probably has problems.<br> I like "Scott Myers" handling of the subject in his books "Effective C++"</p> <blockquote> <p>Good Situations to use Singletons (not many):</p> <ul> <li>Logging frameworks</li> <li>Thread recycling pools</li> </ul> </blockquote> <pre><code>/* * C++ Singleton * Limitation: Single Threaded Design * See: http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf * For problems associated with locking in multi threaded applications * * Limitation: * If you use this Singleton (A) within a destructor of another Singleton (B) * This Singleton (A) must be fully constructed before the constructor of (B) * is called. */ class MySingleton { private: // Private Constructor MySingleton(); // Stop the compiler generating methods of copy the object MySingleton(MySingleton const&amp; copy); // Not Implemented MySingleton&amp; operator=(MySingleton const&amp; copy); // Not Implemented public: static MySingleton&amp; getInstance() { // The only instance // Guaranteed to be lazy initialized // Guaranteed that it will be destroyed correctly static MySingleton instance; return instance; } }; </code></pre> <p>OK. Lets get some criticism and other implementations together.<br> :-)</p>
[ { "answer_id": 86649, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 4, "selected": false, "text": "import static" }, { "answer_id": 86681, "author": "artur02", "author_id": 13937, "author_profile": "https://Stackoverflow.com/users/13937", "pm_score": 0, "selected": false, "text": "using System;\nusing System.Collections;\nusing System.Threading;\n\nnamespace DoFactory.GangOfFour.Singleton.RealWorld\n{\n\n // MainApp test application\n\n class MainApp\n {\n static void Main()\n {\n LoadBalancer b1 = LoadBalancer.GetLoadBalancer();\n LoadBalancer b2 = LoadBalancer.GetLoadBalancer();\n LoadBalancer b3 = LoadBalancer.GetLoadBalancer();\n LoadBalancer b4 = LoadBalancer.GetLoadBalancer();\n\n // Same instance?\n if (b1 == b2 && b2 == b3 && b3 == b4)\n {\n Console.WriteLine(\"Same instance\\n\");\n }\n\n // All are the same instance -- use b1 arbitrarily\n // Load balance 15 server requests\n for (int i = 0; i < 15; i++)\n {\n Console.WriteLine(b1.Server);\n }\n\n // Wait for user\n Console.Read(); \n }\n }\n\n // \"Singleton\"\n\n class LoadBalancer\n {\n private static LoadBalancer instance;\n private ArrayList servers = new ArrayList();\n\n private Random random = new Random();\n\n // Lock synchronization object\n private static object syncLock = new object();\n\n // Constructor (protected)\n protected LoadBalancer()\n {\n // List of available servers\n servers.Add(\"ServerI\");\n servers.Add(\"ServerII\");\n servers.Add(\"ServerIII\");\n servers.Add(\"ServerIV\");\n servers.Add(\"ServerV\");\n }\n\n public static LoadBalancer GetLoadBalancer()\n {\n // Support multithreaded applications through\n // 'Double checked locking' pattern which (once\n // the instance exists) avoids locking each\n // time the method is invoked\n if (instance == null)\n {\n lock (syncLock)\n {\n if (instance == null)\n {\n instance = new LoadBalancer();\n }\n }\n }\n\n return instance;\n }\n\n // Simple, but effective random load balancer\n\n public string Server\n {\n get\n {\n int r = random.Next(servers.Count);\n return servers[r].ToString();\n }\n }\n }\n}\n using System;\nusing System.Collections;\n\nnamespace DoFactory.GangOfFour.Singleton.NETOptimized\n{\n\n // MainApp test application\n\n class MainApp\n {\n\n static void Main()\n {\n LoadBalancer b1 = LoadBalancer.GetLoadBalancer();\n LoadBalancer b2 = LoadBalancer.GetLoadBalancer();\n LoadBalancer b3 = LoadBalancer.GetLoadBalancer();\n LoadBalancer b4 = LoadBalancer.GetLoadBalancer();\n\n // Confirm these are the same instance\n if (b1 == b2 && b2 == b3 && b3 == b4)\n {\n Console.WriteLine(\"Same instance\\n\");\n }\n\n // All are the same instance -- use b1 arbitrarily\n // Load balance 15 requests for a server\n for (int i = 0; i < 15; i++)\n {\n Console.WriteLine(b1.Server);\n }\n\n // Wait for user\n Console.Read(); \n }\n }\n\n // Singleton\n\n sealed class LoadBalancer\n {\n // Static members are lazily initialized.\n // .NET guarantees thread safety for static initialization\n private static readonly LoadBalancer instance =\n new LoadBalancer();\n\n private ArrayList servers = new ArrayList();\n private Random random = new Random();\n\n // Note: constructor is private.\n private LoadBalancer()\n {\n // List of available servers\n servers.Add(\"ServerI\");\n servers.Add(\"ServerII\");\n servers.Add(\"ServerIII\");\n servers.Add(\"ServerIV\");\n servers.Add(\"ServerV\");\n }\n\n public static LoadBalancer GetLoadBalancer()\n {\n return instance;\n }\n\n // Simple, but effective load balancer\n public string Server\n {\n get\n {\n int r = random.Next(servers.Count);\n return servers[r].ToString();\n }\n }\n }\n}\n" }, { "answer_id": 92072, "author": "tenpn", "author_id": 11801, "author_profile": "https://Stackoverflow.com/users/11801", "pm_score": 3, "selected": false, "text": "get()" }, { "answer_id": 761711, "author": "jalf", "author_id": 33213, "author_profile": "https://Stackoverflow.com/users/33213", "pm_score": 6, "selected": false, "text": "std::ostream os;\nos << \"hello world\\n\";\n std::cout << \"hello world\\n\";\n std::cout" }, { "answer_id": 5167914, "author": "CashCow", "author_id": 442284, "author_profile": "https://Stackoverflow.com/users/442284", "pm_score": 0, "selected": false, "text": "namespace {\n\nT1 * pt1 = NULL;\nT2 * pt2 = NULL;\nT3 * pt3 = NULL;\nT4 * pt4 = NULL;\n\n}\n\nint main( int argc, char* argv[])\n{\n T1 t1(args1);\n T2 t2(args2);\n T3 t3(args3);\n T4 t4(args4);\n\n pt1 = &t1;\n pt2 = &t2;\n pt3 = &t3;\n pt4 = &t4;\n\n dostuff();\n\n}\n\nT1& getT1()\n{\n return *pt1;\n}\n\nT2& getT2()\n{\n return *pt2;\n}\n\nT3& getT3()\n{\n return *pt3;\n}\n\nT4& getT4()\n{\n return *pt4;\n}\n" }, { "answer_id": 8771462, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "class Singleton\n{\npublic:\n static Singleton& Instance()\n {\n // lazy initialize\n if (instance_ == NULL) instance_ = new Singleton();\n\n return *instance_;\n }\n\nprivate:\n Singleton() {};\n\n static Singleton *instance_;\n};\n" }, { "answer_id": 51803280, "author": "A. Gupta", "author_id": 5575697, "author_profile": "https://Stackoverflow.com/users/5575697", "pm_score": 2, "selected": false, "text": "#include<iostream>\n#include<mutex>\n\nusing namespace std;\nstd::mutex mtx;\n\nclass MySingleton{\nprivate:\n static MySingleton * singletonInstance;\n MySingleton();\n ~MySingleton();\npublic:\n static MySingleton* GetInstance();\n MySingleton(const MySingleton&) = delete;\n const MySingleton& operator=(const MySingleton&) = delete;\n MySingleton(MySingleton&& other) noexcept = delete;\n MySingleton& operator=(MySingleton&& other) noexcept = delete;\n};\n\nMySingleton* MySingleton::singletonInstance = nullptr;\nMySingleton::MySingleton(){ };\nMySingleton::~MySingleton(){\n delete singletonInstance;\n};\n\nMySingleton* MySingleton::GetInstance(){\n if (singletonInstance == NULL){\n std::lock_guard<std::mutex> lock(mtx);\n if (singletonInstance == NULL)\n singletonInstance = new MySingleton();\n }\n return singletonInstance;\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14065/" ]
86,604
<p>I've run on a little problem today: I have a JS drop down menu and when I inserted a GoogleMap... the Menu is rendered behind the Google Map... Any ideas on how to chance the z Index of the Google Map?</p> <p>Thanks!</p>
[ { "answer_id": 94216, "author": "Jeremy Wadhams", "author_id": 8995, "author_profile": "https://Stackoverflow.com/users/8995", "pm_score": 4, "selected": true, "text": "<SELECT>" }, { "answer_id": 3846592, "author": "Bill Citrine", "author_id": 464701, "author_profile": "https://Stackoverflow.com/users/464701", "pm_score": 2, "selected": false, "text": "#menuWrap #menuWrap {\n position: relative;\n z-index: 9999999\n}\n" }, { "answer_id": 5821155, "author": "electblake", "author_id": 253608, "author_profile": "https://Stackoverflow.com/users/253608", "pm_score": 0, "selected": false, "text": "z-index <div id=\"map\"> z-index auto <ul id=\"rollover\">\n<li><a href=\"#here\">There</a></li>\n</ul>\n<div id=\"map\">...</div>\n" }, { "answer_id": 7153857, "author": "Jason", "author_id": 906689, "author_profile": "https://Stackoverflow.com/users/906689", "pm_score": 0, "selected": false, "text": "onmouseover=\"getElementById('map').style.zIndex = '10000';\" \n\nonmouseout=\"getElementById('map').style.zIndex = '-1';\"\n" }, { "answer_id": 10335450, "author": "brims", "author_id": 959763, "author_profile": "https://Stackoverflow.com/users/959763", "pm_score": 0, "selected": false, "text": "map.controls[google.map.ControlPosition.TOP].push(control);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1657/" ]
86,607
<p>I have two classes, and want to include a static instance of one class inside the other and access the static fields from the second class via the first. </p> <p>This is so I can have non-identical instances with the same name. </p> <pre><code>Class A { public static package1.Foo foo; } Class B { public static package2.Foo foo; } //package1 Foo { public final static int bar = 1; } // package2 Foo { public final static int bar = 2; } // usage assertEquals(A.foo.bar, 1); assertEquals(B.foo.bar, 2); </code></pre> <p>This works, but I get a warning "The static field Foo.bar shoudl be accessed in a static way". Can someone explain why this is and offer a "correct" implementation.</p> <p>I realize I could access the static instances directly, but if you have a long package hierarchy, that gets ugly:</p> <pre><code>assertEquals(net.FooCorp.divisions.A.package.Foo.bar, 1); assertEquals(net.FooCorp.divisions.B.package.Foo.bar, 2); </code></pre>
[ { "answer_id": 86625, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 3, "selected": false, "text": "Foo.bar\n A.foo.bar\n bar Foo bar Foo" }, { "answer_id": 86647, "author": "axk", "author_id": 578, "author_profile": "https://Stackoverflow.com/users/578", "pm_score": 2, "selected": false, "text": "package1.Foo.bar\npackage2.Foo.bar\n" }, { "answer_id": 86679, "author": "Fernando Barrocal", "author_id": 2274, "author_profile": "https://Stackoverflow.com/users/2274", "pm_score": 2, "selected": false, "text": "public static package1.Foo foo;\n" }, { "answer_id": 88200, "author": "jon", "author_id": 12215, "author_profile": "https://Stackoverflow.com/users/12215", "pm_score": 2, "selected": true, "text": "public class A {\n public static class Foo extends package1.Foo {}\n}\npublic class B {\n public static class Foo extends package2.Foo {}\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12982/" ]
86,636
<p>Here is a problem I've struggled with ever since I first started learning object-oriented programming: how should one implement a logger in "proper" OOP code?</p> <p>By this, I mean an object that has a method that we want every other object in the code to be able to access; this method would output to console/file/whatever, which we would use for logging--hence, this object would be the logger object.</p> <p>We don't want to establish the logger object as a global variable, because global variables are bad, right? But we also don't want to have the pass the logger object in the parameters of every single method we call in every single object.</p> <p>In college, when I brought this up to the professor, he couldn't actually give me an answer. I realize that there are actually packages (for say, Java) that might implement this functionality. What I am ultimately looking for, though, is the knowledge of how to properly and in the OOP way implement this myself.</p>
[ { "answer_id": 86702, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 0, "selected": false, "text": "Logger" }, { "answer_id": 238759, "author": "EricSchaefer", "author_id": 8976, "author_profile": "https://Stackoverflow.com/users/8976", "pm_score": 2, "selected": false, "text": "public class MyLogger \n{\n public static void Log(String Message) {}\n}\n public interface ILog \n{\n void Log(String message);\n}\n\npublic class MyLog : ILog \n{\n public void Log(String message) {}\n}\n" }, { "answer_id": 2605756, "author": "Lotus Notes", "author_id": 296308, "author_profile": "https://Stackoverflow.com/users/296308", "pm_score": 0, "selected": false, "text": "new Log();" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16633/" ]
86,653
<p>I would like my JSON output in Ruby on Rails to be "pretty" or nicely formatted. </p> <p>Right now, I call <code>to_json</code> and my JSON is all on one line. At times this can be difficult to see if there is a problem in the JSON output stream.</p> <p>Is there way to configure to make my JSON "pretty" or nicely formatted in Rails?</p>
[ { "answer_id": 1823885, "author": "lambshaanxy", "author_id": 218340, "author_profile": "https://Stackoverflow.com/users/218340", "pm_score": 11, "selected": true, "text": "pretty_generate() require 'json'\nmy_object = { :array => [1, 2, 3, { :sample => \"hash\"} ], :foo => \"bar\" }\nputs JSON.pretty_generate(my_object)\n {\n \"array\": [\n 1,\n 2,\n 3,\n {\n \"sample\": \"hash\"\n }\n ],\n \"foo\": \"bar\"\n}\n" }, { "answer_id": 13029297, "author": "gertas", "author_id": 446210, "author_profile": "https://Stackoverflow.com/users/446210", "pm_score": 6, "selected": false, "text": "curl class PrettyJsonResponse\n def initialize(app)\n @app = app\n end\n\n def call(env)\n status, headers, response = @app.call(env)\n if headers[\"Content-Type\"] =~ /^application\\/json/\n obj = JSON.parse(response.body)\n pretty_str = JSON.pretty_unparse(obj)\n response = [pretty_str]\n headers[\"Content-Length\"] = pretty_str.bytesize.to_s\n end\n [status, headers, response]\n end\nend\n app/middleware/pretty_json_response.rb config/environments/development.rb config.middleware.use PrettyJsonResponse\n production.rb" }, { "answer_id": 14008507, "author": "Christopher Mullins", "author_id": 1924483, "author_profile": "https://Stackoverflow.com/users/1924483", "pm_score": 3, "selected": false, "text": "require \"pp\"\nrequire \"json\"\n\nclass File\n def pp(*objs)\n objs.each {|obj|\n PP.pp(obj, self)\n }\n objs.size <= 1 ? objs.first : objs\n end\n def jj(*objs)\n objs.each {|obj|\n obj = JSON.parse(obj.to_json)\n self.puts JSON.pretty_generate(obj)\n }\n objs.size <= 1 ? objs.first : objs\n end\nend\n\ntest_object = { :name => { first: \"Christopher\", last: \"Mullins\" }, :grades => [ \"English\" => \"B+\", \"Algebra\" => \"A+\" ] }\n\ntest_json_object = JSON.parse(test_object.to_json)\n\nFile.open(\"log/object_dump.txt\", \"w\") do |file|\n file.pp(test_object)\nend\n\nFile.open(\"log/json_dump.txt\", \"w\") do |file|\n file.jj(test_json_object)\nend\n" }, { "answer_id": 17455728, "author": "Roger Garza", "author_id": 1691528, "author_profile": "https://Stackoverflow.com/users/1691528", "pm_score": 7, "selected": false, "text": "<pre> JSON.pretty_generate <% if @data.present? %>\n <pre><%= JSON.pretty_generate(@data) %></pre>\n<% end %>\n" }, { "answer_id": 22776594, "author": "TheDadman", "author_id": 3474708, "author_profile": "https://Stackoverflow.com/users/3474708", "pm_score": 1, "selected": false, "text": " class LogJson\n\n def initialize(app)\n @app = app\n end\n\n def call(env)\n dup._call(env)\n end\n\n def _call(env)\n @status, @headers, @response = @app.call(env)\n [@status, @headers, self]\n end\n\n def each(&block)\n if @headers[\"Content-Type\"] =~ /^application\\/json/\n obj = JSON.parse(@response.body)\n pretty_str = JSON.pretty_unparse(obj)\n @headers[\"Content-Length\"] = Rack::Utils.bytesize(pretty_str).to_s\n Rails.logger.info (\"HTTP Headers: #{ @headers } \")\n Rails.logger.info (\"HTTP Status: #{ @status } \")\n Rails.logger.info (\"JSON Response: #{ pretty_str} \")\n end\n\n @response.each(&block)\n end\n end\n" }, { "answer_id": 22864283, "author": "Thomas Klemm", "author_id": 1606888, "author_profile": "https://Stackoverflow.com/users/1606888", "pm_score": 4, "selected": false, "text": "pp User.first.as_json\n\n# => {\n \"id\" => 1,\n \"first_name\" => \"Polar\",\n \"last_name\" => \"Bear\"\n}\n" }, { "answer_id": 23018176, "author": "Ed Lebert", "author_id": 1050523, "author_profile": "https://Stackoverflow.com/users/1050523", "pm_score": 5, "selected": false, "text": "ActionController::Renderers.add :json do |json, options|\n unless json.kind_of?(String)\n json = json.as_json(options) if json.respond_to?(:as_json)\n json = JSON.pretty_generate(json, options)\n end\n\n if options[:callback].present?\n self.content_type ||= Mime::JS\n \"#{options[:callback]}(#{json})\"\n else\n self.content_type ||= Mime::JSON\n json\n end\nend\n" }, { "answer_id": 26491790, "author": "Wayne Conrad", "author_id": 238886, "author_profile": "https://Stackoverflow.com/users/238886", "pm_score": 3, "selected": false, "text": "class PrettyJsonResponse\n\n def initialize(app)\n @app = app\n end\n\n def call(env)\n @status, @headers, @response = @app.call(env)\n [@status, @headers, self]\n end\n\n def each(&block)\n @response.each do |body|\n if @headers[\"Content-Type\"] =~ /^application\\/json/\n body = pretty_print(body)\n end\n block.call(body)\n end\n end\n\n private\n\n def pretty_print(json)\n obj = JSON.parse(json) \n JSON.pretty_unparse(obj)\n end\n\nend\n config.middleware.use \"PrettyJsonResponse\"\n" }, { "answer_id": 29679793, "author": "Phrogz", "author_id": 405017, "author_profile": "https://Stackoverflow.com/users/405017", "pm_score": 4, "selected": false, "text": "pretty_generate gem install neatjson\n JSON.neat_generate\n JSON.pretty_generate\n pp {\n \"navigation.createroute.poi\":[\n {\"text\":\"Lay in a course to the Hilton\",\"params\":{\"poi\":\"Hilton\"}},\n {\"text\":\"Take me to the airport\",\"params\":{\"poi\":\"airport\"}},\n {\"text\":\"Let's go to IHOP\",\"params\":{\"poi\":\"IHOP\"}},\n {\"text\":\"Show me how to get to The Med\",\"params\":{\"poi\":\"The Med\"}},\n {\"text\":\"Create a route to Arby's\",\"params\":{\"poi\":\"Arby's\"}},\n {\n \"text\":\"Go to the Hilton by the Airport\",\n \"params\":{\"poi\":\"Hilton\",\"location\":\"Airport\"}\n },\n {\n \"text\":\"Take me to the Fry's in Fresno\",\n \"params\":{\"poi\":\"Fry's\",\"location\":\"Fresno\"}\n }\n ],\n \"navigation.eta\":[\n {\"text\":\"When will we get there?\"},\n {\"text\":\"When will I arrive?\"},\n {\"text\":\"What time will I get to the destination?\"},\n {\"text\":\"What time will I reach the destination?\"},\n {\"text\":\"What time will it be when I arrive?\"}\n ]\n}\n" }, { "answer_id": 32404082, "author": "Jim Flood", "author_id": 233596, "author_profile": "https://Stackoverflow.com/users/233596", "pm_score": 2, "selected": false, "text": "class PrettyJson\n def self.dump(object)\n JSON.pretty_generate(object, {:indent => \" \"})\n end\nend\n\nRabl.configure do |config|\n ...\n config.json_engine = PrettyJson if Rails.env.development?\n ...\nend\n ActiveSupport::TimeWithZone.class_eval do\n alias_method :orig_to_s, :to_s\n def to_s(format = :default)\n format == :default ? iso8601 : orig_to_s(format)\n end\nend\n" }, { "answer_id": 33993183, "author": "Sergio Belevskij", "author_id": 1576822, "author_profile": "https://Stackoverflow.com/users/1576822", "pm_score": 2, "selected": false, "text": "\n# example of use:\na_hash = {user_info: {type: \"query_service\", e_mail: \"my@email.com\", phone: \"+79876543322\"}, cars_makers: [\"bmw\", \"mitsubishi\"], car_models: [bmw: {model: \"1er\", year_mfc: 2006}, mitsubishi: {model: \"pajero\", year_mfc: 1997}]}\npretty_html = a_hash.pretty_html\n\n# include this module to your libs:\nmodule MyPrettyPrint\n def pretty_html indent = 0\n result = \"\"\n if self.class == Hash\n self.each do |key, value|\n result += \"#{key}: #{[Array, Hash].include?(value.class) ? value.pretty_html(indent+1) : value}\"\n end\n elsif self.class == Array\n result = \"[#{self.join(', ')}]\"\n end\n \"#{result}\"\n end\n\nend\n\nclass Hash\n include MyPrettyPrint\nend\n\nclass Array\n include MyPrettyPrint\nend\n" }, { "answer_id": 35445669, "author": "sealocal", "author_id": 3238292, "author_profile": "https://Stackoverflow.com/users/3238292", "pm_score": 3, "selected": false, "text": "def index\n my_json = '{ \"key\": \"value\" }'\n render json: JSON.pretty_generate( JSON.parse my_json )\nend\n" }, { "answer_id": 38108045, "author": "Synthead", "author_id": 1713534, "author_profile": "https://Stackoverflow.com/users/1713534", "pm_score": 5, "selected": false, "text": "ap require \"awesome_print\"\nrequire \"json\"\n\njson = '{\"holy\": [\"nested\", \"json\"], \"batman!\": {\"a\": 1, \"b\": 2}}'\n\nap(JSON.parse(json))\n {\n \"holy\" => [\n [0] \"nested\",\n [1] \"json\"\n ],\n \"batman!\" => {\n \"a\" => 1,\n \"b\" => 2\n }\n}\n" }, { "answer_id": 38733065, "author": "oj5th", "author_id": 6583381, "author_profile": "https://Stackoverflow.com/users/6583381", "pm_score": 4, "selected": false, "text": "<pre> pretty_generate <%\n require 'json'\n\n hash = JSON[{hey: \"test\", num: [{one: 1, two: 2, threes: [{three: 3, tthree: 33}]}]}.to_json] \n%>\n\n<pre>\n <%= JSON.pretty_generate(hash) %>\n</pre>\n" }, { "answer_id": 44000539, "author": "Буянбат Чойжилсүрэн", "author_id": 1642675, "author_profile": "https://Stackoverflow.com/users/1642675", "pm_score": 3, "selected": false, "text": "#At Controller\ndef branch\n @data = Model.all\n render json: JSON.pretty_generate(@data.as_json)\nend\n" }, { "answer_id": 56272398, "author": "SergA", "author_id": 1677270, "author_profile": "https://Stackoverflow.com/users/1677270", "pm_score": 2, "selected": false, "text": "my_obj = {\n 'array' => [1, 2, 3, { \"sample\" => \"hash\"}, 44455, 677778, nil ],\n foo: \"bar\", rrr: {\"pid\": 63, \"state with nil and \\\"nil\\\"\": false},\n wwww: 'w' * 74\n}\n require 'pp'\nputs my_obj.as_json.pretty_inspect.\n gsub('=>', ': ').\n gsub(/\"(?:[^\"\\\\]|\\\\.)*\"|\\bnil\\b/) {|m| m == 'nil' ? 'null' : m }.\n gsub(/\\s+$/, \"\")\n {\"array\": [1, 2, 3, {\"sample\": \"hash\"}, 44455, 677778, null],\n \"foo\": \"bar\",\n \"rrr\": {\"pid\": 63, \"state with nil and \\\"nil\\\"\": false},\n \"wwww\":\n \"wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\"}\n\n" }, { "answer_id": 58530985, "author": "Martin Carstens", "author_id": 3485542, "author_profile": "https://Stackoverflow.com/users/3485542", "pm_score": 2, "selected": false, "text": "my_json = '{ \"name\":\"John\", \"age\":30, \"car\":null }'\nputs JSON.pretty_generate(JSON.parse(my_json))\n core dev 1555:0> my_json = '{ \"name\":\"John\", \"age\":30, \"car\":null }'\n=> \"{ \\\"name\\\":\\\"John\\\", \\\"age\\\":30, \\\"car\\\":null }\"\ncore dev 1556:0> puts JSON.pretty_generate(JSON.parse(my_json))\n{\n \"name\": \"John\",\n \"age\": 30,\n \"car\": null\n}\n=> nil\n" }, { "answer_id": 70187118, "author": "TorvaldsDB", "author_id": 7262646, "author_profile": "https://Stackoverflow.com/users/7262646", "pm_score": 2, "selected": false, "text": "puts puts 2.6.0 (main):0 > User.first.to_json\n User Load (0.4ms) SELECT \"users\".* FROM \"users\" ORDER BY \"users\".\"id\" ASC LIMIT $1 [[\"LIMIT\", 1]]\n=> \"{\\\"id\\\":1,\\\"admin\\\":true,\\\"email\\\":\\\"admin@gmail.com\\\",\\\"password_digest\\\":\\\"$2a$10$TQy3P7NT8KrdCzliNUsZzuhmo40LGKoth2hwD3OI.kD0lYiIEwB1y\\\",\\\"created_at\\\":\\\"2021-07-20T08:34:19.350Z\\\",\\\"updated_at\\\":\\\"2021-07-20T08:34:19.350Z\\\",\\\"name\\\":\\\"Arden Stark\\\"}\"\n puts 2.6.0 (main):0 > puts User.first.to_json\n User Load (0.3ms) SELECT \"users\".* FROM \"users\" ORDER BY \"users\".\"id\" ASC LIMIT $1 [[\"LIMIT\", 1]]\n{\"id\":1,\"admin\":true,\"email\":\"admin@gmail.com\",\"password_digest\":\"$2a$10$TQy3P7NT8KrdCzliNUsZzuhmo40LGKoth2hwD3OI.kD0lYiIEwB1y\",\"created_at\":\"2021-07-20T08:34:19.350Z\",\"updated_at\":\"2021-07-20T08:34:19.350Z\",\"name\":\"Arden Stark\"}\n=> nil\n obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}\njson = JSON.pretty_generate(obj)\nputs json\n {\n \"foo\": [\n \"bar\",\n \"baz\"\n ],\n \"bat\": {\n \"bam\": 0,\n \"bad\": 1\n }\n}\n pry-rails rails console awesome_print pry-rails" }, { "answer_id": 72740405, "author": "stevec", "author_id": 5783745, "author_profile": "https://Stackoverflow.com/users/5783745", "pm_score": 0, "selected": false, "text": "data.as_json\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10333/" ]
86,669
<p>Dijkstra's <a href="http://en.wikipedia.org/wiki/Shunting_yard_algorithm" rel="noreferrer" title="Wikipedia: Shunting Yard algorithm">Shunting Yard algorithm</a> is used to parse an infix notation and generate <a href="http://en.wikipedia.org/wiki/Reverse_Polish_notation" rel="noreferrer" title="Wikipedia: Reverse Polish Notation">RPN</a> output.</p> <p>I am looking for the opposite, a way to turn RPN into highschool-math-class style infix notation, in order to represent RPN expressions from a database to lay users in an understandable way.</p> <p>Please save your time and don't cook up the algorithm yourselves, just point me to textbook examples that I can't seem to find. Working backwards from the Shunting Yard algorithm and using my knowledge about the notations I'll probably be able to work up a solution. I'm just looking for a quick shortcut, so I don't have to reinvent the wheel.</p> <p>Oh, and please don't tag this as "homework", I <i>swear</i> I'm out of school already! ;-)</p>
[ { "answer_id": 87004, "author": "Paul Reiners", "author_id": 7648, "author_profile": "https://Stackoverflow.com/users/7648", "pm_score": 3, "selected": false, "text": "(defun rpn-to-inf (pre)\n (if (atom pre)\n pre\n (cond ((eq (car (last pre)) 'setf)\n (list (rpn-to-inf (first pre)) '= (rpn-to-inf (second pre))))\n ((eq (car (last pre)) 'expt)\n (list (rpn-to-inf (first pre)) '^ (rpn-to-inf (second pre))))\n (t (list (rpn-to-inf (first pre)) \n (car (last pre)) \n (rpn-to-inf (second pre)))))))\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2077/" ]
86,685
<p>I am having a really hard time attempting to debug LINQ to SQL and submitting changes.</p> <p>I have been using <a href="http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx" rel="noreferrer">http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-visualizer.aspx</a>, which works great for debugging simple queries.</p> <p>I'm working in the DataContext Class for my project with the following snippet from my application:</p> <pre><code>JobMaster newJobToCreate = new JobMaster(); newJobToCreate.JobID = 9999 newJobToCreate.ProjectID = "New Project"; this.UpdateJobMaster(newJobToCreate); this.SubmitChanges(); </code></pre> <p>I will catch some very odd exceptions when I run this.SubmitChanges;</p> <pre><code>Index was outside the bounds of the array. </code></pre> <p>The stack trace goes places I cannot step into:</p> <pre><code>at System.Data.Linq.IdentityManager.StandardIdentityManager.MultiKeyManager`3.TryCreateKeyFromValues(Object[] values, MultiKey`2&amp; k) at System.Data.Linq.IdentityManager.StandardIdentityManager.IdentityCache`2.Find(Object[] keyValues) at System.Data.Linq.IdentityManager.StandardIdentityManager.Find(MetaType type, Object[] keyValues) at System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues) at System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance) at System.Data.Linq.ChangeProcessor.BuildEdgeMaps() at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) at System.Data.Linq.DataContext.SubmitChanges() at JobTrakDataContext.CreateNewJob(NewJob job, String userName) in D:\JobTrakDataContext.cs:line 1119 </code></pre> <p>Does anyone have any tools or techniques they use? Am I missing something simple?</p> <p><strong>EDIT</strong>: I've setup .net debugging using Slace's suggestion, however the .net 3.5 code is not yet available: <a href="http://referencesource.microsoft.com/netframework.aspx" rel="noreferrer">http://referencesource.microsoft.com/netframework.aspx</a></p> <p><strong>EDIT2</strong>: I've changed to InsertOnSubmit as per sirrocco's suggestion, still getting the same error.</p> <p><strong>EDIT3:</strong> I've implemented Sam's suggestions trying to log the SQL generated and to catch the ChangeExceptoinException. These suggestions do not shed any more light, I'm never actually getting to generate SQL when my exception is being thrown.</p> <p><strong>EDIT4:</strong> I found an answer that works for me below. Its just a theory but it has fixed my current issue.</p>
[ { "answer_id": 90007, "author": "sirrocco", "author_id": 5246, "author_profile": "https://Stackoverflow.com/users/5246", "pm_score": 1, "selected": false, "text": "JobMaster newJobToCreate = new JobMaster();\nnewJobToCreate.JobID = 9999\nnewJobToCreate.ProjectID = \"New Project\";\nthis.InsertOnSubmit(newJobToCreate);\nthis.SubmitChanges();\n" }, { "answer_id": 90025, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 2, "selected": false, "text": "partial void OnCreated()\n{\n#if DEBUG\n this.Log = Console.Out;\n#endif\n}\n" }, { "answer_id": 91510, "author": "Sam", "author_id": 7021, "author_profile": "https://Stackoverflow.com/users/7021", "pm_score": 3, "selected": false, "text": "JobMaster newJobToCreate = new JobMaster();\nnewJobToCreate.JobID = 9999\nnewJobToCreate.ProjectID = \"New Project\";\nthis.UpdateJobMaster(newJobToCreate);\nthis.Log = Console.Out; // prints the SQL to the debug console\nthis.SubmitChanges();\n catch (ChangeConflictException e)\n {\n Console.WriteLine(\"Optimistic concurrency error.\");\n Console.WriteLine(e.Message);\n Console.ReadLine();\n foreach (ObjectChangeConflict occ in db.ChangeConflicts)\n {\n MetaTable metatable = db.Mapping.GetTable(occ.Object.GetType());\n Customer entityInConflict = (Customer)occ.Object;\n Console.WriteLine(\"Table name: {0}\", metatable.TableName);\n Console.Write(\"Customer ID: \");\n Console.WriteLine(entityInConflict.CustomerID);\n foreach (MemberChangeConflict mcc in occ.MemberConflicts)\n {\n object currVal = mcc.CurrentValue;\n object origVal = mcc.OriginalValue;\n object databaseVal = mcc.DatabaseValue;\n MemberInfo mi = mcc.Member;\n Console.WriteLine(\"Member: {0}\", mi.Name);\n Console.WriteLine(\"current value: {0}\", currVal);\n Console.WriteLine(\"original value: {0}\", origVal);\n Console.WriteLine(\"database value: {0}\", databaseVal);\n }\n }\n }\n" }, { "answer_id": 665357, "author": "craziac", "author_id": 79944, "author_profile": "https://Stackoverflow.com/users/79944", "pm_score": 0, "selected": false, "text": "Proce proces = unit.Proces.Single(u => u.ProcesTypeId == (from pt in context.ProcesTypes\n where pt.Name == \"Fix-O\"\n select pt).Single().ProcesTypeId &&\n u.UnitId == UnitId);\n Proce proces = context.Proces.Single(u => u.ProcesTypeId == (from pt in context.ProcesTypes\n where pt.Name == \"Fix-O\"\n select pt).Single().ProcesTypeId &&\n u.UnitId == UnitId);\n" }, { "answer_id": 707320, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 5, "selected": false, "text": "ctx.GetChangeSet();\n" }, { "answer_id": 11529786, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 2, "selected": false, "text": "...\nvar builder = new StringBuilder();\ntry\n{\n context.Log = new StringWriter(builder);\n context.MY_TABLE.InsertAllOnSubmit(someData);\n context.SubmitChanges(); \n}\nfinally\n{\n Log.InfoFormat(\"Some meaningful message here... ={0}\", builder);\n}\n" }, { "answer_id": 53403026, "author": "Mr Zach", "author_id": 4352089, "author_profile": "https://Stackoverflow.com/users/4352089", "pm_score": 0, "selected": false, "text": "CREATE TRIGGER NAME ON TABLE1 AFTER UPDATE AS SELECT table1.key from table1 \ninner join inserted on table1.key = inserted.key\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7561/" ]
86,696
<p>Our ASP.NET application must be able to export web content to PDF and Word documents.</p> <p>In the past, we've used <a href="http://www.aspose.com/" rel="noreferrer">Aspose's</a> libraries to accomplish this, but we've found them to be a little too low-level in terms of document construction. e.g. We've found ourselves needing to write point-based functions using shape primitives to create bulleted lists.</p> <p>Best case scenerio- we'd point a tool at our printable css-styled page and automagically get a PDF or Word document containing the same content styled in the same manner.</p> <p>Have you had a good experience using any tools that could accomplish this?</p>
[ { "answer_id": 92048, "author": "martin", "author_id": 8421, "author_profile": "https://Stackoverflow.com/users/8421", "pm_score": 3, "selected": false, "text": "List overview = new List(false, 10); //false =unordered, true= numbered\noverview.Add(new ListItem(\"This is an item\"));\noverview.Add(\"This is another item\");\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7194/" ]
86,710
<p>I am trying to get a DataGrid under CE 5.0 / .NET CF 2.0 that a user can edit. The document at <a href="http://msdn.microsoft.com/en-us/library/ms838165.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms838165.aspx</a> indicates that some environments do not support editing - </p> <blockquote> <p>As there is no native support for editing in the DataGrid control, this needs to be implemented manually</p> </blockquote> <p>Do I need to implement this ugly example - which doesn't work very well as shown?</p> <p>The documentation is not clear about which .NET features are available on which platform.</p>
[ { "answer_id": 23513709, "author": "Enor", "author_id": 3611488, "author_profile": "https://Stackoverflow.com/users/3611488", "pm_score": 1, "selected": false, "text": "DataTable dataTable = (DataTable)grdOrders.DataSource;\nDataView dataView = dataTable.DefaultView;\n DataView dataView = (DataView)itemdataentryGrid.DataSource;\nDataTable dataTable = dataView.Table;\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1743/" ]
86,726
<p>I have the following type :</p> <pre><code>// incomplete class definition public class Person { private string name; public string Name { get { return this.name; } } } </code></pre> <p>I want this type to be <strong>created</strong> and <strong>updated</strong> with some sort of dedicated controller/builder, but I want it to remain <strong>read-only for other types</strong>.</p> <p>This object also needs to fire an event every time it is updated by its controller/builder.</p> <p>To summary, according to the previous type definition skeleton :</p> <ul> <li>The <code>Person</code> could only be instantiated by a specific controller</li> <li>This controller could <strong>update</strong> the state of the <code>Person</code> (<code>name</code> field) at any time</li> <li>The <code>Person</code> need to send a <strong>notification</strong> to the rest of the world when it occurs</li> <li>All other types should only be able to <strong>read</strong> <code>Person</code> attributes</li> </ul> <p>How should I implement this ? I'm talking about a controller/builder here, but all others solutions are welcome.</p> <p>Note : <em>I would be able to rely on the <code>internal</code> modifier, but ideally all my stuff should be in the same assembly.</em></p>
[ { "answer_id": 86786, "author": "fryguybob", "author_id": 4592, "author_profile": "https://Stackoverflow.com/users/4592", "pm_score": 1, "selected": false, "text": "IPerson public class Creator\n{\n private class Person : IPerson\n {\n public string Name { get; set; }\n }\n\n public IPerson Create(...) ...\n\n\n public void Modify(IPerson person, ...)\n {\n Person dude = person as Person;\n if (dude == null)\n // wasn't created by this class.\n else\n // update the data.\n }\n}\n" }, { "answer_id": 86831, "author": "David Thibault", "author_id": 5903, "author_profile": "https://Stackoverflow.com/users/5903", "pm_score": 0, "selected": false, "text": "public class Person\n{\n public class Editor\n {\n private readonly Person person;\n\n public Editor(Person p)\n {\n person = p;\n }\n\n public void SetName(string name)\n {\n person.name = name;\n }\n\n public static Person Create(string name)\n {\n return new Person(name);\n }\n }\n\n protected string name;\n\n public string Name\n {\n get { return this.name; }\n }\n\n protected Person(string name)\n {\n this.name = name;\n }\n}\n\nPerson p = Person.Editor.Create(\"John\");\nPerson.Editor e = new Person.Editor(p);\ne.SetName(\"Jane\");\n" }, { "answer_id": 86898, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 1, "selected": false, "text": "internal interface IPerson \n{\n Name { get; set; } \n}\n class Person : IPerson \n{\n Name { get; private set; }\n string IPerson.Name { get { return Name; } set { Name = value; } } \n}\n" }, { "answer_id": 87009, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": " /// <summary>\n /// A controlled person. Not production worthy code.\n /// </summary>\n public class Person\n {\n private string _name;\n public string Name\n {\n get { return _name; }\n private set\n {\n _name = value;\n OnNameChanged();\n }\n }\n /// <summary>\n /// This person's controller\n /// </summary>\n public PersonController Controller\n {\n get { return _controller ?? (_controller = new PersonController(this)); }\n }\n private PersonController _controller;\n\n /// <summary>\n /// Fires when <seealso cref=\"Name\"/> changes. Go get the new name yourself.\n /// </summary>\n public event EventHandler NameChanged;\n\n private void OnNameChanged()\n {\n if (NameChanged != null)\n NameChanged(this, EventArgs.Empty);\n }\n\n /// <summary>\n /// A Person controller.\n /// </summary>\n public class PersonController\n {\n Person _slave;\n public PersonController(Person slave)\n {\n _slave = slave;\n }\n /// <summary>\n /// Sets the name on the controlled person.\n /// </summary>\n /// <param name=\"name\">The name to set.</param>\n public void SetName(string name) { _slave.Name = name; }\n }\n }\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4687/" ]
86,763
<p>I'm trying to create a build script for my current project, which includes an Excel Add-in. The Add-in contains a VBProject with a file modGlobal with a variable version_Number. This number needs to be changed for every build. The exact steps:</p> <ol> <li>Open XLA document with Excel.</li> <li>Switch to VBEditor mode. (Alt+F11)</li> <li>Open VBProject, entering a password.</li> <li>Open modGlobal file.</li> <li>Change variable's default value to the current date.</li> <li>Close &amp; save the project.</li> </ol> <p>I'm at a loss for how to automate the process. The best I can come up with is an excel macro or Auto-IT script. I could also write a custom MSBuild task, but that might get... tricky. Does anyone else have any other suggestions?</p>
[ { "answer_id": 119465, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 3, "selected": true, "text": "'\n' ConvertToXla.vbs\n'\n' VBScript to convert an Excel spreadsheet (.xls) into an Excel Add-In (.xla)\n'\n' The script takes two arguments:\n'\n' - the name of the input XLS file.\n'\n' - the name of the output XLA file.\n'\nOption Explicit\nDim nResult\nOn Error Resume Next\nnResult = DoAction\nIf Err.Number <> 0 Then \n Wscript.Echo Err.Description\n Wscript.Quit 1\nEnd If\nWscript.Quit nResult\n\nPrivate Function DoAction()\n\n Dim sInputFile, sOutputFile\n\n Dim argNum, argCount: argCount = Wscript.Arguments.Count\n\n If argCount < 2 Then\n Err.Raise 1, \"ConvertToXla.vbs\", \"Missing argument\"\n End If\n\n sInputFile = WScript.Arguments(0)\n sOutputFile = WScript.Arguments(1)\n\n Dim xlApplication\n\n Set xlApplication = WScript.CreateObject(\"Excel.Application\")\n On Error Resume Next \n ConvertFileToXla xlApplication, sInputFile, sOutputFile\n If Err.Number <> 0 Then \n Dim nErrNumber\n Dim sErrSource\n Dim sErrDescription\n nErrNumber = Err.Number\n sErrSource = Err.Source\n sErrDescription = Err.Description\n xlApplication.Quit\n Err.Raise nErrNumber, sErrSource, sErrDescription\n Else\n xlApplication.Quit\n End If\n\nEnd Function\n\nPublic Sub ConvertFileToXla(xlApplication, sInputFile, sOutputFile)\n\n Dim xlAddIn\n xlAddIn = 18 ' XlFileFormat.xlAddIn\n\n Dim w\n Set w = xlApplication.Workbooks.Open(sInputFile,,,,,,,,,True)\n w.IsAddIn = True\n w.SaveAs sOutputFile, xlAddIn\n w.Close False\nEnd Sub\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1390/" ]
86,766
<p>Often I find myself interacting with files in some way but after writing the code I'm always uncertain how robust it actually is. The problem is that I'm not entirely sure how file related operations can fail and, therefore, the best way to handle exceptions.</p> <p>The simple solution would seem to be just to catch any <code>IOExceptions</code> thrown by the code and give the user an &quot;Inaccessible file&quot; error message, but is it possible to get a bit more fine-grained error messages? Is there a way to determine the difference between such errors as a file being locked by another program and the data being unreadable due to a hardware error?</p> <p>Given the following C# code, how would you handle errors in a user friendly (as informative as possible) way?</p> <pre><code>public class IO { public List&lt;string&gt; ReadFile(string path) { FileInfo file = new FileInfo(path); if (!file.Exists) { throw new FileNotFoundException(); } StreamReader reader = file.OpenText(); List&lt;string&gt; text = new List&lt;string&gt;(); while (!reader.EndOfStream) { text.Add(reader.ReadLine()); } reader.Close(); reader.Dispose(); return text; } public void WriteFile(List&lt;string&gt; text, string path) { FileInfo file = new FileInfo(path); if (!file.Exists) { throw new FileNotFoundException(); } StreamWriter writer = file.CreateText(); foreach(string line in text) { writer.WriteLine(line); } writer.Flush(); writer.Close(); writer.Dispose(); } } </code></pre>
[ { "answer_id": 86855, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 3, "selected": false, "text": "using (StreamReader reader = file.OpenText())\n{\n List<string> text = new List<string>();\n while (!reader.EndOfStream)\n {\n text.Add(reader.ReadLine());\n }\n}\n StreamReader reader = file.OpenText();\ntry\n{\n List<string> text = new List<string>();\n while (!reader.EndOfStream)\n {\n text.Add(reader.ReadLine());\n }\n}\nfinally\n{\n if (reader != null)\n ((IDisposable)reader).Dispose();\n}\n" }, { "answer_id": 86916, "author": "Brian", "author_id": 1750627, "author_profile": "https://Stackoverflow.com/users/1750627", "pm_score": 0, "selected": false, "text": " using (TextWriter w = File.CreateText(\"log.txt\")) {\n w.WriteLine(\"This is line one\");\n w.WriteLine(\"This is line two\");\n }\n using (TextReader r = File.OpenText(\"log.txt\")) {\n string s;\n while ((s = r.ReadLine()) != null) {\n Console.WriteLine(s);\n }\n }\n" }, { "answer_id": 86942, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 1, "selected": false, "text": "public IList<string> ReadFile(string path)\n{\n List<string> text = new List<string>();\n using(StreamReader reader = new StreamReader(path))\n {\n while (!reader.EndOfStream) \n { \n text.Add(reader.ReadLine()); \n }\n }\n return text;\n}\n" }, { "answer_id": 90627, "author": "Dustman", "author_id": 16398, "author_profile": "https://Stackoverflow.com/users/16398", "pm_score": 5, "selected": true, "text": "IOException Exception.ToString() Exception throw new FileNotFoundException(\"File not found\"); using using catch try { \n using (StreamReader reader = file.OpenText()) { \n // Your processing code here \n } \n} catch (IOException e) { \n UI.AlertUserSomehow(e.ToString()); \n} using try catch catch IOException Exception.ToString() catch" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4055/" ]
86,780
<p>Say I have two strings,</p> <pre><code>String s1 = "AbBaCca"; String s2 = "bac"; </code></pre> <p>I want to perform a check returning that <code>s2</code> is contained within <code>s1</code>. I can do this with:</p> <pre><code>return s1.contains(s2); </code></pre> <p>I am pretty sure that <code>contains()</code> is case sensitive, however I can't determine this for sure from reading the documentation. If it is then I suppose my best method would be something like:</p> <pre><code>return s1.toLowerCase().contains(s2.toLowerCase()); </code></pre> <p>All this aside, is there another (possibly better) way to accomplish this without caring about case-sensitivity?</p>
[ { "answer_id": 86832, "author": "Dave L.", "author_id": 3093, "author_profile": "https://Stackoverflow.com/users/3093", "pm_score": 9, "selected": true, "text": "Pattern.compile(Pattern.quote(wantedStr), Pattern.CASE_INSENSITIVE).matcher(source).find();\n" }, { "answer_id": 90780, "author": "Matt Quail", "author_id": 15790, "author_profile": "https://Stackoverflow.com/users/15790", "pm_score": 8, "selected": false, "text": "\\d Pattern.compile(Pattern.quote(s2), Pattern.CASE_INSENSITIVE).matcher(s1).find();\n" }, { "answer_id": 2647156, "author": "Bilbo Baggins", "author_id": 317728, "author_profile": "https://Stackoverflow.com/users/317728", "pm_score": 4, "selected": false, "text": "String s1 = \"abBaCca\";\nString s2 = \"bac\";\n\nString s1Lower = s1;\n\n//s1Lower is exact same string, now convert it to lowercase, I left the s1 intact for print purposes if needed\n\ns1Lower = s1Lower.toLowerCase();\n\nString trueStatement = \"FALSE!\";\nif (s1Lower.contains(s2)) {\n\n //THIS statement will be TRUE\n trueStatement = \"TRUE!\"\n}\n\nreturn trueStatement;\n" }, { "answer_id": 4397645, "author": "IVY", "author_id": 536324, "author_profile": "https://Stackoverflow.com/users/536324", "pm_score": -1, "selected": false, "text": "String x=\"abCd\";\nSystem.out.println(Pattern.compile(\"c\",Pattern.CASE_INSENSITIVE).matcher(x).find());\n" }, { "answer_id": 8883863, "author": "Phil", "author_id": 763080, "author_profile": "https://Stackoverflow.com/users/763080", "pm_score": 5, "selected": false, "text": "String String foobar = \"fooBar\";\nString bar = \"FOO\";\nif (foobar.toLowerCase().contains(bar.toLowerCase()) {\n System.out.println(\"It's a match!\");\n}\n" }, { "answer_id": 9560307, "author": "muhamadto", "author_id": 901982, "author_profile": "https://Stackoverflow.com/users/901982", "pm_score": 8, "selected": false, "text": "org.apache.commons.lang3.StringUtils.containsIgnoreCase(\"AbBaCca\", \"bac\");\n" }, { "answer_id": 12984575, "author": "Shiv", "author_id": 1140407, "author_profile": "https://Stackoverflow.com/users/1140407", "pm_score": 3, "selected": false, "text": "boolean found = s1.matches(\"(?i).*\" + s2+ \".*\");\n" }, { "answer_id": 21153922, "author": "Jan Newmarch", "author_id": 1897195, "author_profile": "https://Stackoverflow.com/users/1897195", "pm_score": 2, "selected": false, "text": "for (SongInformation song: songs) {\n if (song.artist.toLowerCase().indexOf(pattern.toLowercase() > -1) {\n ...\n }\n}\n for (SongInformation song: songs) {\n if (song.artist.matches(\"(?i).*\" + pattern + \".*\")) {\n ...\n }\n}\n Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);\nMatcher m = p.matcher(\"\");\nfor (SongInformation song: songs) {\n m.reset(song.artist);\n if (m.find()) {\n ...\n }\n}\n" }, { "answer_id": 21640291, "author": "seth", "author_id": 3285967, "author_profile": "https://Stackoverflow.com/users/3285967", "pm_score": 0, "selected": false, "text": "String container = \" Case SeNsitive \";\nString sub = \"sen\";\nif (rcontains(container, sub)) {\n System.out.println(\"no case\");\n}\n\npublic static Boolean rcontains(String container, String sub) {\n\n Boolean b = false;\n for (int a = 0; a < container.length() - sub.length() + 1; a++) {\n //System.out.println(sub + \" to \" + container.substring(a, a+sub.length()));\n if (sub.equalsIgnoreCase(container.substring(a, a + sub.length()))) {\n b = true;\n }\n }\n return b;\n}\n for equalsIgnoreCase" }, { "answer_id": 23892141, "author": "Hakanai", "author_id": 138513, "author_profile": "https://Stackoverflow.com/users/138513", "pm_score": 2, "selected": false, "text": "public static boolean containsIgnoreCase(String haystack, String needle) {\n return indexOfIgnoreCase(haystack, needle) >= 0;\n}\n\npublic static int indexOfIgnoreCase(String haystack, String needle) {\n StringSearch stringSearch = new StringSearch(needle, haystack);\n stringSearch.getCollator().setStrength(Collator.PRIMARY);\n return stringSearch.first();\n}\n" }, { "answer_id": 25379180, "author": "icza", "author_id": 1705598, "author_profile": "https://Stackoverflow.com/users/1705598", "pm_score": 7, "selected": false, "text": "String.regionMatches() toLowerCase() String ignoreCase public static boolean containsIgnoreCase(String src, String what) {\n final int length = what.length();\n if (length == 0)\n return true; // Empty string is contained\n \n final char firstLo = Character.toLowerCase(what.charAt(0));\n final char firstUp = Character.toUpperCase(what.charAt(0));\n \n for (int i = src.length() - length; i >= 0; i--) {\n // Quick check before calling the more expensive regionMatches() method:\n final char ch = src.charAt(i);\n if (ch != firstLo && ch != firstUp)\n continue;\n \n if (src.regionMatches(true, i, what, 0, length))\n return true;\n }\n \n return false;\n}\n String.contains() String.contains() Pattern.compile().matcher().find() Pattern Pattern RELATIVE SPEED 1/RELATIVE SPEED\n METHOD EXEC TIME TO SLOWEST TO FASTEST (#1)\n------------------------------------------------------------------------------\n 1. Using regionMatches() 670 ms 10.7x 1.0x\n 2. 2x lowercase+contains 2829 ms 2.5x 4.2x\n 3. 1x lowercase+contains cache 2446 ms 2.9x 3.7x\n 4. Regexp 7180 ms 1.0x 10.7x\n 5. Regexp+cached pattern 1845 ms 3.9x 2.8x\n contains() Pattern import java.util.regex.Pattern;\n\npublic class ContainsAnalysis {\n \n // Case 1 utilizing String.regionMatches()\n public static boolean containsIgnoreCase(String src, String what) {\n final int length = what.length();\n if (length == 0)\n return true; // Empty string is contained\n \n final char firstLo = Character.toLowerCase(what.charAt(0));\n final char firstUp = Character.toUpperCase(what.charAt(0));\n \n for (int i = src.length() - length; i >= 0; i--) {\n // Quick check before calling the more expensive regionMatches()\n // method:\n final char ch = src.charAt(i);\n if (ch != firstLo && ch != firstUp)\n continue;\n \n if (src.regionMatches(true, i, what, 0, length))\n return true;\n }\n \n return false;\n }\n \n // Case 2 with 2x toLowerCase() and contains()\n public static boolean containsConverting(String src, String what) {\n return src.toLowerCase().contains(what.toLowerCase());\n }\n \n // The cached substring for case 3\n private static final String S = \"i am\".toLowerCase();\n \n // Case 3 with pre-cached substring and 1x toLowerCase() and contains()\n public static boolean containsConverting(String src) {\n return src.toLowerCase().contains(S);\n }\n \n // Case 4 with regexp\n public static boolean containsIgnoreCaseRegexp(String src, String what) {\n return Pattern.compile(Pattern.quote(what), Pattern.CASE_INSENSITIVE)\n .matcher(src).find();\n }\n \n // The cached pattern for case 5\n private static final Pattern P = Pattern.compile(\n Pattern.quote(\"i am\"), Pattern.CASE_INSENSITIVE);\n \n // Case 5 with pre-cached Pattern\n public static boolean containsIgnoreCaseRegexp(String src) {\n return P.matcher(src).find();\n }\n \n // Main method: perfroms speed analysis on different contains methods\n // (case ignored)\n public static void main(String[] args) throws Exception {\n final String src = \"Hi, I am Adam\";\n final String what = \"i am\";\n \n long start, end;\n final int N = 10_000_000;\n \n start = System.nanoTime();\n for (int i = 0; i < N; i++)\n containsIgnoreCase(src, what);\n end = System.nanoTime();\n System.out.println(\"Case 1 took \" + ((end - start) / 1000000) + \"ms\");\n \n start = System.nanoTime();\n for (int i = 0; i < N; i++)\n containsConverting(src, what);\n end = System.nanoTime();\n System.out.println(\"Case 2 took \" + ((end - start) / 1000000) + \"ms\");\n \n start = System.nanoTime();\n for (int i = 0; i < N; i++)\n containsConverting(src);\n end = System.nanoTime();\n System.out.println(\"Case 3 took \" + ((end - start) / 1000000) + \"ms\");\n \n start = System.nanoTime();\n for (int i = 0; i < N; i++)\n containsIgnoreCaseRegexp(src, what);\n end = System.nanoTime();\n System.out.println(\"Case 4 took \" + ((end - start) / 1000000) + \"ms\");\n \n start = System.nanoTime();\n for (int i = 0; i < N; i++)\n containsIgnoreCaseRegexp(src);\n end = System.nanoTime();\n System.out.println(\"Case 5 took \" + ((end - start) / 1000000) + \"ms\");\n }\n \n}\n" }, { "answer_id": 29485939, "author": "Revertron", "author_id": 2605687, "author_profile": "https://Stackoverflow.com/users/2605687", "pm_score": 0, "selected": false, "text": "public static String lowerCaseAscii(String s) {\n if (s == null)\n return null;\n\n int len = s.length();\n char[] buf = new char[len];\n s.getChars(0, len, buf, 0);\n for (int i=0; i<len; i++) {\n if (buf[i] >= 'A' && buf[i] <= 'Z')\n buf[i] += 0x20;\n }\n\n return new String(buf);\n}\n\npublic static boolean containsIgnoreCaseAscii(String str, String searchStr) {\n return StringUtils.contains(lowerCaseAscii(str), lowerCaseAscii(searchStr));\n}\n" }, { "answer_id": 34069545, "author": "Erick Kondela", "author_id": 5635648, "author_profile": "https://Stackoverflow.com/users/5635648", "pm_score": -1, "selected": false, "text": "String s1 = \"AbBaCca\";\nString s2 = \"bac\";\nString toLower = s1.toLowerCase();\nreturn toLower.contains(s2);\n" }, { "answer_id": 40508106, "author": "Stéphane GRILLON", "author_id": 3535537, "author_profile": "https://Stackoverflow.com/users/3535537", "pm_score": 0, "selected": false, "text": "import java.text.Normalizer;\n\nimport org.apache.commons.lang3.StringUtils;\n\npublic class ContainsIgnoreCase {\n\n public static void main(String[] args) {\n\n String in = \" Annulée \";\n String key = \"annulee\";\n\n // 100% java\n if (Normalizer.normalize(in, Normalizer.Form.NFD).replaceAll(\"[\\\\p{InCombiningDiacriticalMarks}]\", \"\").toLowerCase().contains(key)) {\n System.out.println(\"OK\");\n } else {\n System.out.println(\"KO\");\n }\n\n // use commons.lang lib\n if (StringUtils.containsIgnoreCase(Normalizer.normalize(in, Normalizer.Form.NFD).replaceAll(\"[\\\\p{InCombiningDiacriticalMarks}]\", \"\"), key)) {\n System.out.println(\"OK\");\n } else {\n System.out.println(\"KO\");\n }\n\n }\n\n}\n" }, { "answer_id": 47787761, "author": "Takhir Atamuratov", "author_id": 4793760, "author_profile": "https://Stackoverflow.com/users/4793760", "pm_score": 2, "selected": false, "text": "\"AbCd\".toLowerCase().contains(\"abcD\".toLowerCase())\n" }, { "answer_id": 55967261, "author": "Soudipta Dutta", "author_id": 6037956, "author_profile": "https://Stackoverflow.com/users/6037956", "pm_score": 0, "selected": false, "text": "public class Test2 {\n public static void main(String[] args) {\n\n String a = \"Gina Gini Protijayi Soudipta\";\n String b = \"Gini\";\n\n System.out.println(WordPresentOrNot(a, b));\n }// main\n\n private static boolean WordPresentOrNot(String a, String b) {\n //contains is case sensitive. That's why change it to upper or lower case. Then check\n // Here we are using stream with anyMatch\n boolean match = Arrays.stream(a.toLowerCase().split(\" \")).anyMatch(b.toLowerCase()::contains);\n return match;\n }\n\n}\n" }, { "answer_id": 55980176, "author": "Mr.Q", "author_id": 3593084, "author_profile": "https://Stackoverflow.com/users/3593084", "pm_score": 2, "selected": false, "text": " String s1 = \"hello abc efg\";\n String s2 = \"ABC\";\n s1.matches(\".*(?i)\"+s2+\".*\");\n\n/*\n * .* denotes every character except line break\n * (?i) denotes case insensitivity flag enabled for s2 (String)\n * */\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2628/" ]
86,790
<p>I'm designing a web site navigation hierarchy. It's a tree of nodes. Nodes represent web pages.</p> <p>Some nodes on the tree are special. I need a name for them.</p> <p>There are multiple such nodes. Each is the "root" of a sub-tree with pages that have a distinct logo, style sheet, or layout. Think of different departments.</p> <p><a href="http://img518.imageshack.us/img518/153/subtreesfe1.gif" rel="nofollow noreferrer">site map with color-coded sub-trees http://img518.imageshack.us/img518/153/subtreesfe1.gif</a></p> <p>What should I name this type of node?</p>
[ { "answer_id": 86851, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://Stackoverflow.com/users/2260", "pm_score": 1, "selected": false, "text": "AreaNode" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
86,793
<p>If a user select all items in a .NET 2.0 ListView, the ListView will fire a <strong>SelectedIndexChanged</strong> event for every item, rather than firing an event to indicate that the <em>selection</em> has changed.</p> <p>If the user then clicks to select just one item in the list, the ListView will fire a <strong>SelectedIndexChanged</strong> event for <em>every</em> item that is getting unselected, and then an <strong>SelectedIndexChanged</strong> event for the single newly selected item, rather than firing an event to indicate that the selection has changed.</p> <p>If you have code in the <strong>SelectedIndexChanged</strong> event handler, the program will become pretty unresponsive when you begin to have a few hundred/thousand items in the list.</p> <p>I've thought about <em>dwell timers</em>, etc.</p> <p>But does anyone have a good solution to avoid thousands of needless ListView.<strong>SelectedIndexChange</strong> events, when really <strong>one event</strong> will do?</p>
[ { "answer_id": 87204, "author": "Ian Boyd", "author_id": 12597, "author_profile": "https://Stackoverflow.com/users/12597", "pm_score": 2, "selected": false, "text": "Timer changeDelayTimer = null;\n\nprivate void lvResults_SelectedIndexChanged(object sender, EventArgs e)\n{\n if (this.changeDelayTimer == null)\n {\n this.changeDelayTimer = new Timer();\n this.changeDelayTimer.Tick += ChangeDelayTimerTick;\n this.changeDelayTimer.Interval = 200; //200ms is what Explorer uses\n }\n this.changeDelayTimer.Enabled = false;\n this.changeDelayTimer.Enabled = true;\n}\n\nprivate void ChangeDelayTimerTick(object sender, EventArgs e)\n{\n this.changeDelayTimer.Enabled = false;\n this.changeDelayTimer.Dispose();\n this.changeDelayTimer = null;\n\n //Add original SelectedIndexChanged event handler code here\n //todo\n}\n" }, { "answer_id": 980971, "author": "Robert Jeppesen", "author_id": 9436, "author_profile": "https://Stackoverflow.com/users/9436", "pm_score": 5, "selected": true, "text": " public class DoublebufferedListView : System.Windows.Forms.ListView\n {\n private Timer m_changeDelayTimer = null;\n public DoublebufferedListView()\n : base()\n {\n // Set common properties for our listviews\n if (!SystemInformation.TerminalServerSession)\n {\n DoubleBuffered = true;\n SetStyle(ControlStyles.ResizeRedraw, true);\n }\n }\n\n /// <summary>\n /// Make sure to properly dispose of the timer\n /// </summary>\n /// <param name=\"disposing\"></param>\n protected override void Dispose(bool disposing)\n {\n if (disposing && m_changeDelayTimer != null)\n {\n m_changeDelayTimer.Tick -= ChangeDelayTimerTick;\n m_changeDelayTimer.Dispose();\n }\n base.Dispose(disposing);\n }\n\n /// <summary>\n /// Hack to avoid lots of unnecessary change events by marshaling with a timer:\n /// http://stackoverflow.com/questions/86793/how-to-avoid-thousands-of-needless-listview-selectedindexchanged-events\n /// </summary>\n /// <param name=\"e\"></param>\n protected override void OnSelectedIndexChanged(EventArgs e)\n {\n if (m_changeDelayTimer == null)\n {\n m_changeDelayTimer = new Timer();\n m_changeDelayTimer.Tick += ChangeDelayTimerTick;\n m_changeDelayTimer.Interval = 40;\n }\n // When a new SelectedIndexChanged event arrives, disable, then enable the\n // timer, effectively resetting it, so that after the last one in a batch\n // arrives, there is at least 40 ms before we react, plenty of time \n // to wait any other selection events in the same batch.\n m_changeDelayTimer.Enabled = false;\n m_changeDelayTimer.Enabled = true;\n }\n\n private void ChangeDelayTimerTick(object sender, EventArgs e)\n {\n m_changeDelayTimer.Enabled = false;\n base.OnSelectedIndexChanged(new EventArgs());\n }\n }\n" }, { "answer_id": 1090045, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "bool timer_event_should_call_update_controls = false;\n\nprivate void lvwMyListView_SelectedIndexChanged(object sender, EventArgs e) {\n\n timer_event_should_call_update_controls = true;\n}\n\nprivate void UpdateControlsTimer_Tick(object sender, EventArgs e) {\n\n if (timer_event_should_call_update_controls) {\n timer_event_should_call_update_controls = false;\n\n update_controls();\n }\n}\n" }, { "answer_id": 1091035, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 0, "selected": false, "text": "ListView DataGridView" }, { "answer_id": 3651216, "author": "Anthony Urwin", "author_id": 321104, "author_profile": "https://Stackoverflow.com/users/321104", "pm_score": 1, "selected": false, "text": "// ################ CODE STARTS HERE ################\n//Flag to create at the form level\nSystem.Boolean lsvLoadFlag = true;\n\n//Make sure to set the flag to true at the begin of the form load and after\nprivate void frmMain_Load(object sender, EventArgs e)\n{\n //Prevent the listview from firing crazy in a single click NOT multislect environment\n lsvLoadFlag = true;\n\n //DO SOME CODE....\n\n //Enable the listview to process events\n lsvLoadFlag = false;\n}\n\n//Populate First then this line of code\nlsvMain.Items[0].Selected = true;\n\n//SelectedIndexChanged Event\n private void lsvMain_SelectedIndexChanged(object sender, EventArgs e)\n{\n ListViewItem lvi = null;\n\n if (!lsvLoadFlag)\n {\n if (this.lsvMain.SelectedIndices != null)\n {\n if (this.lsvMain.SelectedIndices.Count == 1)\n {\n lvi = this.lsvMain.Items[this.lsvMain.SelectedIndices[0]];\n }\n }\n }\n}\n################ CODE END HERE ################\n" }, { "answer_id": 4045889, "author": "Ian Boyd", "author_id": 12597, "author_profile": "https://Stackoverflow.com/users/12597", "pm_score": 0, "selected": false, "text": "LVN_ODSTATECHANGED LVN_ITEMCHANGED [iFrom..iTo] LVN_ODSTATECHANGED iFrom=0 iTo=499999 LVN_ITEMCHANGED" }, { "answer_id": 7005667, "author": "Kind Contributor", "author_id": 887092, "author_profile": "https://Stackoverflow.com/users/887092", "pm_score": 0, "selected": false, "text": "ListViewItem ItemOnMouseDown = null;\nprivate void lvTransactions_MouseDown(object sender, MouseEventArgs e)\n{\n ItemOnMouseDown = lvTransactions.GetItemAt(e.X, e.Y);\n}\nprivate void lvTransactions_SelectedIndexChanged(object sender, EventArgs e)\n{\n if (ItemOnMouseDown != null && lvTransactions.SelectedIndices.Count == 0)\n return;\n\n SelectedIndexDidReallyChange();\n\n}\n" }, { "answer_id": 21136142, "author": "Jack Culhane", "author_id": 1805643, "author_profile": "https://Stackoverflow.com/users/1805643", "pm_score": 2, "selected": false, "text": "public class ListViewNF : ListView\n{\n bool SelectedIndexChanging = false;\n\n public ListViewNF()\n {\n this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);\n this.SetStyle(ControlStyles.EnableNotifyMessage, true);\n }\n\n protected override void OnNotifyMessage(Message m)\n {\n if(m.Msg != 0x14)\n base.OnNotifyMessage(m);\n }\n\n protected override void OnSelectedIndexChanged(EventArgs e)\n {\n SelectedIndexChanging = true;\n //base.OnSelectedIndexChanged(e);\n }\n\n protected override void OnMouseUp(MouseEventArgs e)\n {\n if (SelectedIndexChanging)\n {\n base.OnSelectedIndexChanged(EventArgs.Empty);\n SelectedIndexChanging = false;\n }\n\n base.OnMouseUp(e);\n }\n\n protected override void OnKeyUp(KeyEventArgs e)\n {\n if (SelectedIndexChanging)\n {\n base.OnSelectedIndexChanged(EventArgs.Empty);\n SelectedIndexChanging = false;\n }\n\n base.OnKeyUp(e);\n }\n}\n" }, { "answer_id": 42375473, "author": "Amir Saniyan", "author_id": 309798, "author_profile": "https://Stackoverflow.com/users/309798", "pm_score": 1, "selected": false, "text": "async await private bool waitForUpdateControls = false;\n\nprivate async void listView_SelectedIndexChanged(object sender, EventArgs e)\n{\n // To avoid thousands of needless ListView.SelectedIndexChanged events.\n\n if (waitForUpdateControls)\n {\n return;\n }\n\n waitForUpdateControls = true;\n\n await Task.Delay(100);\n\n waitForUpdateControls = false;\n\n UpdateControls();\n\n return;\n}\n" }, { "answer_id": 73822533, "author": "Beeeaaar", "author_id": 714557, "author_profile": "https://Stackoverflow.com/users/714557", "pm_score": 0, "selected": false, "text": " void OnClick(object sender, EventArgs e)\n {\n if (this.isInitialize) // kind of pedantic\n return;\n\n if (this.SelectedIndices.Count > 0)\n {\n string value = this.SelectedItems[0].Tag;\n if (value != null)\n {\n this.OutValue = value;\n }\n }\n\n //NOTE: if this close is done in SelectedIndexChanged, will crash\n // with corrupted memory error if an item was already selected\n\n // Tell property grid to close the wrapper Form\n var editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;\n if ((object)editorService != null)\n {\n editorService.CloseDropDown();\n }\n }\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
86,797
<p>I've got two controls in my Interface Builder file, and each of those controls I've created a separate delegate class for in code (Control1Delegate and Control2Delegate). I created two "Objects" in interface builder, made them of that type, and connected the controls to them as delegates. The delegates work just fine. My problem is, I need to share information from one delegate to the other delegate, and I'm not sure how. </p> <p>What is the best way to do this? Combine the two delegates into one class, or somehow access a third class that they can both read? Since I'm not actually initializing the class anywhere in my code, I'm not sure how to get a reference to the actual instance of it (if there is an actual instance of it), or even access the "main" class that the project came with.</p>
[ { "answer_id": 88063, "author": "Barry Wark", "author_id": 2140, "author_profile": "https://Stackoverflow.com/users/2140", "pm_score": 4, "selected": true, "text": "IBOutlet id outletToOtherDelegate; awakeFromNib awakeFromNib" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15813/" ]
86,800
<p>I've recently embarked upon the <em>grand voyage</em> of Wordpress theming and I've been reading through the Wordpress documentation for how to write a theme. One thing I came across <a href="http://codex.wordpress.org/Theme_Development" rel="nofollow noreferrer">here</a> was that the <code>style.css</code> file must contain a specific header in order to be used by the Wordpress engine. They give a brief example but I haven't been able to turn up any formal description of what must be in the <code>style.css</code> header portion. Does this exist on the Wordpress site? If it doesn't could we perhaps describe it here?</p>
[ { "answer_id": 86841, "author": "Martin", "author_id": 15840, "author_profile": "https://Stackoverflow.com/users/15840", "pm_score": 1, "selected": false, "text": "/*\nTHEME NAME: Parallax\nTHEME URI: http://parallaxdenigrate.net\nVERSION: .1\nAUTHOR: Martin Jacobsen\nAUTHOR URI: http://martinjacobsen.no\n*/\n" }, { "answer_id": 86860, "author": "cori", "author_id": 8151, "author_profile": "https://Stackoverflow.com/users/8151", "pm_score": 4, "selected": true, "text": "/* \nTheme Name: Rose\nTheme URI: the-theme's-homepage\nDescription: a-brief-description\nAuthor: your-name\nAuthor URI: your-URI\nTemplate: use-this-to-define-a-parent-theme--optional\nVersion: a-number--optional\nTags: a-comma-delimited-list--optional\n.\nGeneral comments/License Statement if any.\n.\n*/\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16562/" ]
86,824
<p>I'm getting a <code>ConnectException: Connection timed out</code> with some frequency from my code. The URL I am trying to hit is up. The same code works for some users, but not others. It seems like once one user starts to get this exception they continue to get the exception.</p> <p>Here is the stack trace:</p> <pre><code>java.net.ConnectException: Connection timed out Caused by: java.net.ConnectException: Connection timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.Socket.connect(Socket.java:516) at java.net.Socket.connect(Socket.java:466) at sun.net.NetworkClient.doConnect(NetworkClient.java:157) at sun.net.www.http.HttpClient.openServer(HttpClient.java:365) at sun.net.www.http.HttpClient.openServer(HttpClient.java:477) at sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:214) at sun.net.www.http.HttpClient.New(HttpClient.java:287) at sun.net.www.http.HttpClient.New(HttpClient.java:299) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:796) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:748) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:673) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:840) </code></pre> <p>Here is a snippet from my code:</p> <pre><code>URLConnection urlConnection = null; OutputStream outputStream = null; OutputStreamWriter outputStreamWriter = null; InputStream inputStream = null; try { URL url = new URL(urlBase); urlConnection = url.openConnection(); urlConnection.setDoOutput(true); outputStream = urlConnection.getOutputStream(); // exception occurs on this line outputStreamWriter = new OutputStreamWriter(outputStream); outputStreamWriter.write(urlString); outputStreamWriter.flush(); inputStream = urlConnection.getInputStream(); String response = IOUtils.toString(inputStream); return processResponse(urlString, urlBase, response); } catch (IOException e) { throw new Exception("Error querying url: " + urlString, e); } finally { IoUtil.close(inputStream); IoUtil.close(outputStreamWriter); IoUtil.close(outputStream); } </code></pre>
[ { "answer_id": 87352, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 3, "selected": false, "text": "urlConnection.setConnectTimeout(1000);\n" }, { "answer_id": 327614, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "tracert traceroute" }, { "answer_id": 47595100, "author": "NikNik", "author_id": 7604006, "author_profile": "https://Stackoverflow.com/users/7604006", "pm_score": 2, "selected": false, "text": "System.setProperty(\"https.proxyHost\", \"myProxy\");\nSystem.setProperty(\"https.proxyPort\", \"80\");\n http.proxyHost" }, { "answer_id": 61482047, "author": "Lonzak", "author_id": 2311528, "author_profile": "https://Stackoverflow.com/users/2311528", "pm_score": 2, "selected": false, "text": "setFixedLengthStreamingMode" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16677/" ]
86,849
<p>If I have the following:</p> <pre><code>{"hdrs": ["Make","Model","Year"], "data" : [ {"Make":"Honda","Model":"Accord","Year":"2008"} {"Make":"Toyota","Model":"Corolla","Year":"2008"} {"Make":"Honda","Model":"Pilot","Year":"2008"}] } </code></pre> <p>And I have a "hdrs" name (i.e. "Make"), how can I reference the <code>data</code> array instances? seems like <code>data["Make"][0]</code> should work...but unable to get the right reference</p> <p><strong>EDIT</strong> </p> <p>Sorry for the ambiguity.. I can loop through <code>hdrs</code> to get each hdr name, but I need to use each instance value of <code>hdrs</code> to find all the data elements in <code>data</code> (not sure that is any better of an explanation). and I will have it in a variable <code>t</code> since it is JSON (appreciate the re-tagging) I would like to be able to reference with something like this: <code>t.data[hdrs[i]][j]</code></p>
[ { "answer_id": 86903, "author": "Stephen Wrighton", "author_id": 7516, "author_profile": "https://Stackoverflow.com/users/7516", "pm_score": 0, "selected": false, "text": "var x = data[0].Make;\nvar z = data[0].Model;\nvar y = data[0].Year;\n" }, { "answer_id": 86909, "author": "Domenic", "author_id": 3191, "author_profile": "https://Stackoverflow.com/users/3191", "pm_score": 1, "selected": false, "text": "var theMap = /* the stuff you posted */;\nvar someHdr = \"Make\";\nvar whichIndex = 0;\nvar correspondingData = theMap[\"data\"][whichIndex][someHdr];\n" }, { "answer_id": 86922, "author": "Jared", "author_id": 1980, "author_profile": "https://Stackoverflow.com/users/1980", "pm_score": 3, "selected": true, "text": "var x = {\"hdrs\": [\"Make\",\"Model\",\"Year\"],\n \"data\" : [ \n {\"Make\":\"Honda\",\"Model\":\"Accord\",\"Year\":\"2008\"},\n {\"Make\":\"Toyota\",\"Model\":\"Corolla\",\"Year\":\"2008\"},\n {\"Make\":\"Honda\",\"Model\":\"Pilot\",\"Year\":\"2008\"}]\n };\n\n alert( x.data[0].Make );\n var x = {\"hdrs\": [\"Make\",\"Model\",\"Year\"],\n \"data\" : [ \n {\"Make\":\"Honda\",\"Model\":\"Accord\",\"Year\":\"2008\"},\n {\"Make\":\"Toyota\",\"Model\":\"Corolla\",\"Year\":\"2008\"},\n {\"Make\":\"Honda\",\"Model\":\"Pilot\",\"Year\":\"2008\"}]\n };\nvar Header = 0; // Make\nfor( var i = 0; i <= x.data.length - 1; i++ )\n{\n alert( x.data[i][x.hdrs[Header]] );\n} \n" }, { "answer_id": 86925, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 1, "selected": false, "text": "var x = {\"hdrs\": [\"Make\",\"Model\",\"Year\"],\n \"data\" : [ \n {\"Make\":\"Honda\",\"Model\":\"Accord\",\"Year\":\"2008\"}\n {\"Make\":\"Toyota\",\"Model\":\"Corolla\",\"Year\":\"2008\"}\n {\"Make\":\"Honda\",\"Model\":\"Pilot\",\"Year\":\"2008\"}]\n};\n\nx.data[0].Make == \"Honda\"\nx['data'][0]['Make'] == \"Honda\"\n" }, { "answer_id": 86929, "author": "DGM", "author_id": 14253, "author_profile": "https://Stackoverflow.com/users/14253", "pm_score": 0, "selected": false, "text": "$foo = {\"hdrs\": [\"Make\",\"Model\",\"Year\"],\n \"data\" : [ \n {\"Make\":\"Honda\",\"Model\":\"Accord\",\"Year\":\"2008\"},\n {\"Make\":\"Toyota\",\"Model\":\"Corolla\",\"Year\":\"2008\"},\n {\"Make\":\"Honda\",\"Model\":\"Pilot\",\"Year\":\"2008\"}]\n};\n $foo[\"data\"][0][\"make\"]\n" }, { "answer_id": 86931, "author": "just mike", "author_id": 12293, "author_profile": "https://Stackoverflow.com/users/12293", "pm_score": 2, "selected": false, "text": "var obj_hash = {\n \"hdrs\": [\"Make\", \"Model\", \"Year\"],\n \"data\": [\n {\"Make\": \"Honda\", \"Model\": \"Accord\", \"Year\": \"2008\"},\n {\"Make\": \"Toyota\", \"Model\": \"Corolla\", \"Year\": \"2008\"},\n {\"Make\": \"Honda\", \"Model\": \"Pilot\", \"Year\": \"2008\"},\n ]\n};\n\nvar ref_data = obj_hash.data;\n\nalert(ref_data[0].Make);" }, { "answer_id": 86932, "author": "noah", "author_id": 12034, "author_profile": "https://Stackoverflow.com/users/12034", "pm_score": 1, "selected": false, "text": "obj.data[0][\"Make\"] // == \"Honda\"\n obj.data[0][obj.hdrs[0]] // == \"Honda\"\n" }, { "answer_id": 87374, "author": "Jay Corbett", "author_id": 2755, "author_profile": "https://Stackoverflow.com/users/2755", "pm_score": 0, "selected": false, "text": "var t = eval( \"(\" + request + \")\" ) ;\nfor (var i = 0; i < t.data.length; i++) {\n myTable += \"<tr>\";\n for (var j = 0; j < t.hdrs.length; j++) {\n myTable += \"<td>\" ;\n if (t.data[i][t.hdrs[j]] == \"\") {myTable += \"&nbsp;\" ; }\n else { myTable += t.data[i][t.hdrs[j]] ; }\n myTable += \"</td>\";\n }\n myTable += \"</tr>\";\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
86,878
<p>I am having problem that even though I specify the level to ERROR in the root tag, the specified appender logs all levels (debug, info, warn) to the file regardless the settings. I am not a Log4j expert so any help is appreciated.</p> <p>I have checked the classpath for log4j.properties (there is none) except the log4j.xml.</p> <p>Here is the log4j.xml file:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt; &lt;!DOCTYPE log4j:configuration SYSTEM &quot;log4j.dtd&quot;&gt; &lt;log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'&gt; &lt;!-- ============================== --&gt; &lt;!-- Append messages to the console --&gt; &lt;!-- ============================== --&gt; &lt;appender name=&quot;console&quot; class=&quot;org.apache.log4j.ConsoleAppender&quot;&gt; &lt;param name=&quot;Target&quot; value=&quot;System.out&quot; /&gt; &lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt; &lt;!-- The default pattern: Date Priority [Category] Message\n --&gt; &lt;param name=&quot;ConversionPattern&quot; value=&quot;[AC - %5p] [%d{ISO8601}] [%t] [%c{1} - %L] %m%n&quot; /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name=&quot;logfile&quot; class=&quot;org.apache.log4j.RollingFileAppender&quot;&gt; &lt;param name=&quot;File&quot; value=&quot;./logs/server.log&quot; /&gt; &lt;param name=&quot;MaxFileSize&quot; value=&quot;1000KB&quot; /&gt; &lt;param name=&quot;MaxBackupIndex&quot; value=&quot;2&quot; /&gt; &lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt; &lt;param name=&quot;ConversionPattern&quot; value=&quot;[AC - %-5p] {%d{dd.MM.yyyy - HH.mm.ss}} %m%n&quot; /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name=&quot;payloadAppender&quot; class=&quot;org.apache.log4j.RollingFileAppender&quot;&gt; &lt;param name=&quot;File&quot; value=&quot;./logs/payload.log&quot; /&gt; &lt;param name=&quot;MaxFileSize&quot; value=&quot;1000KB&quot; /&gt; &lt;param name=&quot;MaxBackupIndex&quot; value=&quot;10&quot; /&gt; &lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt; &lt;param name=&quot;ConversionPattern&quot; value=&quot;[AC - %-5p] {%d{dd.MM.yyyy - HH.mm.ss}} %m%n&quot; /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name=&quot;errorLog&quot; class=&quot;org.apache.log4j.RollingFileAppender&quot;&gt; &lt;param name=&quot;File&quot; value=&quot;./logs/error.log&quot; /&gt; &lt;param name=&quot;MaxFileSize&quot; value=&quot;1000KB&quot; /&gt; &lt;param name=&quot;MaxBackupIndex&quot; value=&quot;10&quot; /&gt; &lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt; &lt;param name=&quot;ConversionPattern&quot; value=&quot;[AC - %-5p] {%d{dd.MM.yyyy - HH.mm.ss}} %m%n&quot; /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name=&quot;traceLog&quot; class=&quot;org.apache.log4j.RollingFileAppender&quot;&gt; &lt;param name=&quot;File&quot; value=&quot;./logs/trace.log&quot; /&gt; &lt;param name=&quot;MaxFileSize&quot; value=&quot;1000KB&quot; /&gt; &lt;param name=&quot;MaxBackupIndex&quot; value=&quot;20&quot; /&gt; &lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&gt; &lt;param name=&quot;ConversionPattern&quot; value=&quot;[AccessControl - %-5p] {%t: %d{dd.MM.yyyy - HH.mm.ss,SSS}} %m%n&quot; /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;appender name=&quot;traceSocketAppender&quot; class=&quot;org.apache.log4j.net.SocketAppender&quot;&gt; &lt;param name=&quot;remoteHost&quot; value=&quot;localhost&quot; /&gt; &lt;param name=&quot;port&quot; value=&quot;4445&quot; /&gt; &lt;param name=&quot;locationInfo&quot; value=&quot;true&quot; /&gt; &lt;/appender&gt; &lt;logger name=&quot;TraceLogger&quot;&gt; &lt;level value=&quot;trace&quot; /&gt; &lt;!-- Set level to trace to activate tracing --&gt; &lt;appender-ref ref=&quot;traceLog&quot; /&gt; &lt;/logger&gt; &lt;logger name=&quot;org.springframework.ws.server.endpoint.interceptor&quot;&gt; &lt;level value=&quot;DEBUG&quot; /&gt; &lt;appender-ref ref=&quot;payloadAppender&quot; /&gt; &lt;/logger&gt; &lt;root&gt; &lt;level value=&quot;error&quot; /&gt; &lt;appender-ref ref=&quot;errorLog&quot; /&gt; &lt;/root&gt; &lt;/log4j:configuration&gt; </code></pre> <p>If I replace the root with another logger, then nothing gets logged at all to the specified appender.</p> <pre class="lang-xml prettyprint-override"><code>&lt;logger name=&quot;com.mydomain.logic&quot;&gt; &lt;level value=&quot;error&quot; /&gt; &lt;appender-ref ref=&quot;errorLog&quot; /&gt; &lt;/logger&gt; </code></pre>
[ { "answer_id": 87151, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 3, "selected": false, "text": "-Dlog4j.debug" }, { "answer_id": 87644, "author": "Michael", "author_id": 13379, "author_profile": "https://Stackoverflow.com/users/13379", "pm_score": 2, "selected": false, "text": "log4j.properties" }, { "answer_id": 3475120, "author": "monzonj", "author_id": 119693, "author_profile": "https://Stackoverflow.com/users/119693", "pm_score": 6, "selected": false, "text": "console root logger L L L's console <logger name=\"org.springframework.ws.server.endpoint.interceptor\"\n additivity=\"false\">\n <level value=\"DEBUG\" />\n <appender-ref ref=\"payloadAppender\" />\n</logger>\n log4j.logger.org.springframework.ws.server.endpoint.interceptor = INFO, payloadAppender\nlog4j.additivity.org.springframework.ws.server.endpoint.interceptor = false\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15045/" ]
86,901
<p>I would like a panel in GWT to fill the page without actually having to set the size. Is there a way to do this? Currently I have the following:</p> <pre><code>public class Main implements EntryPoint { public void onModuleLoad() { HorizontalSplitPanel split = new HorizontalSplitPanel(); //split.setSize("250px", "500px"); split.setSplitPosition("30%"); DecoratorPanel dp = new DecoratorPanel(); dp.setWidget(split); RootPanel.get().add(dp); } } </code></pre> <p>With the previous code snippet, nothing shows up. Is there a method call I am missing?</p> <p>Thanks.</p> <hr> <p><strong>UPDATE Sep 17 '08 at 20:15</strong> </p> <p>I put some buttons (explicitly set their size) on each side and that still doesn't work. I'm really surprised there isn't like a FillLayout class or a setFillLayout method or setDockStyle(DockStyle.Fill) or something like that. Maybe it's not possible? But for as popular as GWT is, I would think it would be possible.</p> <p><strong>UPDATE Sep 18 '08 at 14:38</strong> </p> <p>I have tried setting the RootPanel width and height to 100% and that still didn't work. Thanks for the suggestion though, that seemed like it maybe was going to work. Any other suggestions??</p>
[ { "answer_id": 97037, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 0, "selected": false, "text": "split.setWidth(\"100%\");\nsplit.setHeight(\"100%\");\n" }, { "answer_id": 958857, "author": "Ben Bederson", "author_id": 114575, "author_profile": "https://Stackoverflow.com/users/114575", "pm_score": 5, "selected": true, "text": "final VerticalPanel vp = new VerticalPanel();\nvp.add(mainPanel);\nvp.setWidth(\"100%\");\nvp.setHeight(Window.getClientHeight() + \"px\");\nWindow.addResizeHandler(new ResizeHandler() {\n\n public void onResize(ResizeEvent event) {\n int height = event.getHeight();\n vp.setHeight(height + \"px\");\n }\n});\nRootPanel.get().add(vp);\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10333/" ]
86,905
<p>In <a href="https://stackoverflow.com/questions/48669/are-there-any-tools-out-there-to-compare-the-structure-of-2-web-pages">this post</a> I asked if there were any tools that compare the structure (not actual content) of 2 HTML pages. I ask because I receive HTML templates from our designers, and frequently miss minor formatting changes in my implementation. I then waste a few hours of designer time sifting through my pages to find my mistakes. </p> <p>The thread offered some good suggestions, but there was nothing that fit the bill. "Fine, then", thought I, "I'll just crank one out myself. I'm a halfway-decent developer, right?".</p> <p>Well, once I started to think about it, I couldn't quite figure out how to go about it. I can crank out a data-driven website easily enough, or do a CMS implementation, or throw documents in and out of BizTalk all day. Can't begin to figure out how to compare HTML docs.</p> <p>Well, sure, I have to read the DOM, and iterate through the nodes. I have to map the structure to some data structure (how??), and then compare them (how??). It's a development task like none I've ever attempted.</p> <p>So now that I've identified a weakness in my knowledge, I'm even more challenged to figure this out. Any suggestions on how to get started?</p> <p>clarification: the actual <i>content</i> isn't what I want to compare -- the creative guys fill their pages with <i>lorem ipsum</i>, and I use real content. Instead, I want to compare structure:</p> <pre> &lt;div class="foo"&gt;lorem ipsum&lt;div&gt;</pre> <p>is different that</p> <pre> <br/>&lt;div class="foo"&gt;<br/>&lt;p&gt;lorem ipsum&lt;p&gt;<br/>&lt;div&gt;</pre>
[ { "answer_id": 87022, "author": "Martin08", "author_id": 8203, "author_profile": "https://Stackoverflow.com/users/8203", "pm_score": 0, "selected": false, "text": "?<=^|>)[^><]+?(?=<|$ \"\"" }, { "answer_id": 87129, "author": "raldi", "author_id": 7598, "author_profile": "https://Stackoverflow.com/users/7598", "pm_score": 2, "selected": false, "text": "#! /usr/bin/perl -w\n\nuse strict;\n\nundef $/;\n\nmy $html = <STDIN>;\n\nwhile ($html =~ /\\S/) {\n if ($html =~ s/^\\s*<//) {\n $html =~ s/^(.*?)>// or die \"malformed HTML\";\n print \"<$1>\\n\";\n } else {\n $html =~ s/^([^<]+)//;\n print \"(text)\\n\";\n }\n}\n" }, { "answer_id": 92347, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<div id=\"ctl00_TopNavHome_DivHeader\" class=\"header4\">foo</div>\n<div class=\"header4\">foo</div>\n" }, { "answer_id": 1414685, "author": "Nick", "author_id": 14072, "author_profile": "https://Stackoverflow.com/users/14072", "pm_score": 0, "selected": false, "text": "<div> <div id=\"mainContent\">\n<p>lorem ipsum etc..</p>\n</div>\n <div id=\"mainContent\">\n<p>Here is some real content<img class=\"someImage\" src=\"someImage.jpg\" /></p>\n<ul>\n<li>and</li>\n<li>some</li>\n<li>more..</li>\n</ul>\n</div>\n" }, { "answer_id": 2531933, "author": "hdhoang", "author_id": 303447, "author_profile": "https://Stackoverflow.com/users/303447", "pm_score": 0, "selected": false, "text": "html5lib" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
86,907
<p>I'm using exim on both the sending and relay hosts, the sending host seems to offer:</p> <pre><code>HELO foo_bar.example.com </code></pre> <p>Response: </p> <pre><code>501 Syntactically invalid HELO argument(s) </code></pre>
[ { "answer_id": 89160, "author": "Jörg W Mittag", "author_id": 2988, "author_profile": "https://Stackoverflow.com/users/2988", "pm_score": 0, "selected": false, "text": "HELO" }, { "answer_id": 8723533, "author": "Mazatec", "author_id": 220519, "author_profile": "https://Stackoverflow.com/users/220519", "pm_score": 0, "selected": false, "text": "/var/qmail/control/me /var/qmail/control/helohost (none)" }, { "answer_id": 36863784, "author": "Digao", "author_id": 2668689, "author_profile": "https://Stackoverflow.com/users/2668689", "pm_score": 1, "selected": false, "text": "127.0.0.1 localhost 127.0.0.1 localhost proplad" }, { "answer_id": 37950125, "author": "Arnold", "author_id": 3634166, "author_profile": "https://Stackoverflow.com/users/3634166", "pm_score": 1, "selected": false, "text": "127.0.0.1 localhost susetest\n" }, { "answer_id": 66546695, "author": "Kris", "author_id": 10069862, "author_profile": "https://Stackoverflow.com/users/10069862", "pm_score": 0, "selected": false, "text": "local_domain = \"localhost\"\n local_domain" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12850/" ]
86,911
<p>I am looking for a tool that can serialize and/or transform SQL Result Sets into XML. Getting dumbed down XML generation from SQL result sets is simple and trivial, but that's not what I need.</p> <p>The solution has to be database neutral, and accepts only regular SQL query results (no db xml support used). A particular challenge of this tool is to provide nested XML matching any schema from row based results. Intermediate steps are too slow and wasteful - this needs to happen in one single step; no RS->object->XML, preferably no RS->XML->XSLT->XML. It must support streaming due to large result sets, big XML.</p> <p>Anything out there for this?</p>
[ { "answer_id": 86978, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 2, "selected": false, "text": "#!/usr/bin/env jruby\n\nimport java.sql.DriverManager\n\n# TODO some magic to load the driver\nconn = DriverManager.getConnection(ARGV[0], ARGV[1], ARGV[2])\nres = conn.executeQuery ARGV[3]\n\nputs \"<result>\"\nmeta = res.meta_data\nwhile res.next\n puts \"<row>\"\n\n for n in 1..meta.column_count\n column = meta.getColumnName n\n puts \"<#{column}>#{res.getString(n)}</#{column}\"\n end \n\n puts \"</row>\"\nend\nputs \"</result>\"\n" }, { "answer_id": 7494219, "author": "Rodney Barbati", "author_id": 956040, "author_profile": "https://Stackoverflow.com/users/956040", "pm_score": 0, "selected": false, "text": "<[FieldName]> merge()" }, { "answer_id": 7494252, "author": "Rodney Barbati", "author_id": 956040, "author_profile": "https://Stackoverflow.com/users/956040", "pm_score": 1, "selected": false, "text": "SELECT \n '<Record>' ||\n '<name>' || name || '</name>' ||\n '<address>' || address || '</address>' ||\n '</Record>'\nFROM\n contacts\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10034/" ]
86,919
<p>I have a simple xml document that looks like the following snippet. I need to write a XSLT transform that basically 'unpivots' this document based on some of the attributes.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;root xmlns:z="foo"&gt; &lt;z:row A="1" X="2" Y="n1" Z="500"/&gt; &lt;z:row A="2" X="5" Y="n2" Z="1500"/&gt; &lt;/root&gt; </code></pre> <p>This is what I expect the output to be -</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;root xmlns:z="foo"&gt; &lt;z:row A="1" X="2" /&gt; &lt;z:row A="1" Y="n1" /&gt; &lt;z:row A="1" Z="500"/&gt; &lt;z:row A="2" X="5" /&gt; &lt;z:row A="2" Y="n2"/&gt; &lt;z:row A="2" Z="1500"/&gt; &lt;/root&gt; </code></pre> <p>Appreciate your help.</p>
[ { "answer_id": 87086, "author": "Darrel Miller", "author_id": 6819, "author_profile": "https://Stackoverflow.com/users/6819", "pm_score": 0, "selected": false, "text": "<xsl:template match=\"z:row\">\n <xsl:element name=\"z:row\">\n <xsl:attribute name=\"A\">\n <xsl:value-of select=\"@A\"/>\n </xsl:attribute>\n <xsl:attribute name=\"X\">\n <xsl:value-of select=\"@X\"/>\n </xsl:attribute>\n </xsl:element>\n <xsl:element name=\"z:row\">\n <xsl:attribute name=\"A\">\n <xsl:value-of select=\"@A\"/>\n </xsl:attribute>\n <xsl:attribute name=\"Y\">\n <xsl:value-of select=\"@Y\"/>\n </xsl:attribute>\n </xsl:element>\n <xsl:element name=\"z:row\">\n <xsl:attribute name=\"A\">\n <xsl:value-of select=\"@A\"/>\n </xsl:attribute>\n <xsl:attribute name=\"Z\">\n <xsl:value-of select=\"@Z\"/>\n </xsl:attribute>\n </xsl:element>\n</xsl:template>\n\n\n<xsl:template match=\"@* | node()\">\n <xsl:copy>\n <xsl:apply-templates select=\"@* | node()\"/>\n </xsl:copy>\n</xsl:template>\n" }, { "answer_id": 87097, "author": "Steve Jessop", "author_id": 13005, "author_profile": "https://Stackoverflow.com/users/13005", "pm_score": 2, "selected": true, "text": "<xsl:template match=\"row\">\n <row A=\"{$A}\" X=\"{$X}\" />\n <row A=\"{$A}\" Y=\"{$Y}\" />\n <row A=\"{$A}\" Z=\"{$Z}\" />\n</xsl:template>\n" }, { "answer_id": 87228, "author": "Garth Gilmour", "author_id": 2635682, "author_profile": "https://Stackoverflow.com/users/2635682", "pm_score": 1, "selected": false, "text": "<xsl:template match=\"z:row\">\n <xsl:variable name=\"attr\" select=\"@A\"/>\n <xsl:for-each select=\"@*[(local-name() != 'A')]\">\n <xsl:element name=\"z:row\">\n <xsl:copy-of select=\"$attr\"/>\n <xsl:attribute name=\"{name()}\"><xsl:value-of select=\".\"/></xsl:attribute>\n </xsl:element>\n </xsl:for-each>\n</xsl:template>\n" }, { "answer_id": 90919, "author": "JeniT", "author_id": 6739, "author_profile": "https://Stackoverflow.com/users/6739", "pm_score": 2, "selected": false, "text": "<xsl:stylesheet version=\"1.0\"\n xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n xmlns:z=\"foo\">\n\n<xsl:template match=\"root\">\n <root>\n <xsl:apply-templates />\n </root>\n</xsl:template>\n\n<xsl:template match=\"z:row\">\n <xsl:variable name=\"A\" select=\"@A\" />\n <xsl:for-each select=\"@*[local-name() != 'A']\">\n <z:row A=\"{$A}\">\n <xsl:attribute name=\"{local-name()}\">\n <xsl:value-of select=\".\" />\n </xsl:attribute>\n </z:row>\n </xsl:for-each>\n</xsl:template>\n\n</xsl:stylesheet>\n <z:row> <xsl:element> {} <xsl:attribute> <xsl:element> <xsl:attribute> except select <xsl:attribute> <xsl:stylesheet version=\"2.0\"\n xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n exclude-result-prefixes=\"xs\"\n xmlns:z=\"foo\">\n\n<xsl:template match=\"root\">\n <root>\n <xsl:apply-templates />\n </root>\n</xsl:template>\n\n<xsl:template match=\"z:row\">\n <xsl:variable name=\"A\" as=\"xs:string\" select=\"@A\" />\n <xsl:for-each select=\"@* except @A\">\n <z:row A=\"{$A}\">\n <xsl:attribute name=\"{local-name()}\" select=\".\" />\n </z:row>\n </xsl:for-each>\n</xsl:template>\n\n</xsl:stylesheet>\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4088/" ]
86,947
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/73713/how-do-i-check-for-nulls-in-an-operator-overload-without-infinite-recursion">How do I check for nulls in an &#39;==&#39; operator overload without infinite recursion?</a> </p> </blockquote> <p>When I overload the == operator for objects I typically write something like this:</p> <pre><code> public static bool operator ==(MyObject uq1, MyObject uq2) { if (((object)uq1 == null) || ((object)uq2 == null)) return false; return uq1.Field1 == uq2.Field1 &amp;&amp; uq1.Field2 == uq2.Field2; } </code></pre> <p>If you don't down-cast to object the function recurses into itself but I have to wonder if there isn't a better way?</p>
[ { "answer_id": 86986, "author": "Timothy Carter", "author_id": 4660, "author_profile": "https://Stackoverflow.com/users/4660", "pm_score": 0, "selected": false, "text": "if ((object)uq1 == null) \n return ((object)uq2 == null)\nelse if ((object)uq2 == null)\n return false;\nelse\n //return normal comparison\n" }, { "answer_id": 87008, "author": "Purfideas", "author_id": 4615, "author_profile": "https://Stackoverflow.com/users/4615", "pm_score": -1, "selected": false, "text": "null == <anything> is always false\n" }, { "answer_id": 87403, "author": "ripper234", "author_id": 11236, "author_profile": "https://Stackoverflow.com/users/11236", "pm_score": 0, "selected": false, "text": "public class Foo : IEquatable<Foo>\n{\n public static bool operator !=(Foo foo1, Foo foo2)\n {\n return !Equals(foo1, foo2);\n }\n\n public static bool operator ==(Foo foo1, Foo foo2)\n {\n return Equals(foo1, foo2);\n }\n\n public bool Equals(Foo foo)\n {\n if (foo == null) return false;\n return y == foo.y && x == foo.x;\n }\n\n public override bool Equals(object obj)\n {\n if (ReferenceEquals(this, obj)) return true;\n return Equals(obj as Foo);\n }\n\n public override int GetHashCode()\n {\n return y + 29*x;\n }\n\n private int y;\n private int x;\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
86,949
<p>Unix.....>>netstat -al | grep 8787 (will see packets on port 8787)</p>
[ { "answer_id": 177920, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 0, "selected": false, "text": "-s 0 -X" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13143/" ]
86,963
<p>More than once I've lost work by accidentally killing a temporary buffer in Emacs. Can I set up Emacs to give me a warning when I kill a buffer not associated with a file?</p>
[ { "answer_id": 87080, "author": "EfForEffort", "author_id": 14113, "author_profile": "https://Stackoverflow.com/users/14113", "pm_score": 5, "selected": true, "text": "kill-buffer-query-functions buffer-file-name (defun maybe-kill-buffer ()\n (if (and (not buffer-file-name)\n (buffer-modified-p))\n ;; buffer is not visiting a file\n (y-or-n-p \"This buffer is not visiting a file but has been edited. Kill it anyway? \")\n t))\n (add-to-list 'kill-buffer-query-functions 'maybe-kill-buffer)\n" }, { "answer_id": 87281, "author": "cjm", "author_id": 8355, "author_profile": "https://Stackoverflow.com/users/8355", "pm_score": 2, "selected": false, "text": "(defun maybe-kill-buffer ()\n (if (and (not buffer-file-name)\n (buffer-modified-p))\n ;; buffer is not visiting a file\n (y-or-n-p (format \"Buffer %s has been edited. Kill it anyway? \"\n (buffer-name)))\n t))\n\n(add-to-list 'kill-buffer-query-functions 'maybe-kill-buffer)\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207/" ]
86,987
<p>I'm trying this with Oracle SQL Developer and am on an Intel MacBook Pro. But I believe this same error happens with other clients. I can ping the server hosting the database fine so it appears not to be an actual network problem.</p> <p>Also, I believe I'm filling in the connection info correctly. It's something like this:</p> <pre> host = foo1.com port = 1530 server = DEDICATED service_name = FOO type = session method = basic </pre>
[ { "answer_id": 124193, "author": "dreeves", "author_id": 4234, "author_profile": "https://Stackoverflow.com/users/4234", "pm_score": 1, "selected": true, "text": "Host=blessedhost\nHostName=blessedhost.whatever.com\nUser=alice\nCompression=yes\nProtocol=2\nLocalForward=2202 oraclemachine.whatever.com:1521\n\nHost=foo\nHostName=localhost\nPort=2202\nUser=alice\nCompression=yes\nProtocol=2\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
86,992
<p>I have an application with multiple &quot;pick list&quot; entities, such as used to populate choices of dropdown selection boxes. These entities need to be stored in the database. How do one persist these entities in the database?</p> <p>Should I create a new table for each pick list? Is there a better solution?</p>
[ { "answer_id": 87014, "author": "neouser99", "author_id": 10669, "author_profile": "https://Stackoverflow.com/users/10669", "pm_score": 0, "selected": false, "text": "select optionDesc from Options where 'MyList' = optionList\n" }, { "answer_id": 87051, "author": "Blorgbeard", "author_id": 369, "author_profile": "https://Stackoverflow.com/users/369", "pm_score": 4, "selected": true, "text": "PickListContent\n\nIdList IdPick Text \n1 1 Apples\n1 2 Oranges\n1 3 Pears\n2 1 Dogs\n2 2 Cats\n PickList\n\nId Description\n1 Fruit\n2 Pets\n" }, { "answer_id": 87064, "author": "theo", "author_id": 7870, "author_profile": "https://Stackoverflow.com/users/7870", "pm_score": 3, "selected": false, "text": "CREATE TABLE PickList(\n ListName varchar(15),\n Value varchar(15),\n Display varchar(15),\n Primary Key (ListName, Display)\n)\n" }, { "answer_id": 87070, "author": "Adrian Dunston", "author_id": 8344, "author_profile": "https://Stackoverflow.com/users/8344", "pm_score": 1, "selected": false, "text": " # Put in the name of the list\n insert into lists (id, name) values (1, \"Country in North America\");\n\n # Put in the values of the list\n insert into list_options (id, list_id, value_text) values\n (1, 1, \"Canada\"),\n (2, 1, \"United States of America\"),\n (3, 1, \"Mexico\");\n" }, { "answer_id": 87104, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 0, "selected": false, "text": "SQL> desc aux_values;\n Name Type\n ----------------------------------------- ------------\n VARIABLE_ID VARCHAR2(20)\n VALUE_SEQ NUMBER\n DESCRIPTION VARCHAR2(80)\n INTEGER_VALUE NUMBER\n CHAR_VALUE VARCHAR2(40)\n FLOAT_VALUE FLOAT(126)\n ACTIVE_FLAG VARCHAR2(1)\n" }, { "answer_id": 87211, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "id - identity or UUID field (I actually call the field xxx_id where xxx is the name of the table). \nname - display name of the item \ndisplay_order - small int of order to display. Default this value to something greater than 1 \n \"SELECT id, name FROM theTable ORDER BY display_order, name\" and set the display_order value for the US as 1, Canada as 2 and all other countries as 9." } ]
2008/09/17
[ "https://Stackoverflow.com/questions/86992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8852/" ]
87,007
<p>We've got some in-house applications built in MFC, with OpenGL drawing routines. They all use the same code to draw on the screen and either print the screen or save it to a JPEG file. Everything's been working fine in Windows XP, and I need to find a way to make them work on Vista.</p> <p>In three of our applications, everything works. In the remaining one, I can get the window border, title bar, menus, and task bar, but the interior never shows up. As I said, these applications use the exact same code to write to the screen and capture the window image, and the only difference I see that looks like it might be relevant is that the problem application uses the MFC multiple document interface, while the ones that work use the single document interface.</p> <p>Either the answer isn't on the net, or I'm worse at Googling than I thought. I asked on the MSDN forums, and the only practical suggestion I got was to use GDI+ rather than GDI, and that did nothing different. I have tried different things with every part of the code that captures and prints or save, given a pointer to the window, so apparently it's a matter of the window itself. I haven't rebuilt the offending application using SDI yet, and I really don't have any other ideas.</p> <p>Has anybody seen anything like this?</p> <hr> <p>What I've got is four applications. They use a lot of common code, and share the actual .h and .cpp files, so I know the drawing and screen capture code is identical.</p> <p>There is a WindowtoDIB() routine that takes a *pWnd, and a source rectangle and destination size. It looks like very slightly adapted Microsoft code, and I've found other functions in this file on the Microsoft website. Of my four applications, three handle this just fine, but one doesn't. The most obvious difference is that the problem one is MDI.</p> <p>It looks to me like the *pWnd is the problem. I'm not a MFC guru by a long shot, and it seems to me that the problem may be that we've got one window setup in the SDIs, and more than one in the MDI. I may be passing the wrong *pWnd to the function.</p> <p>In the meantime, it has started working properly on the 64-bit Vista test machine, although it still doesn't work on the 32-bit Vista machine. I have no idea why. I haven't changed anything since the last tests, and I didn't think anybody else had. (On the 32-bit version, the Print Screen key works as expected, but it does not save the screen as a JPEG.)</p>
[ { "answer_id": 95881, "author": "Roel", "author_id": 11449, "author_profile": "https://Stackoverflow.com/users/11449", "pm_score": 1, "selected": false, "text": "mainfrm = static_cast<CMainFrame*>(::AfxGetMainWnd()); - mainfrm\n\n- mainfrm->MDIGetActive()\n\n- mainfrm->MDIGetActive()->GetActiveView()\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14148/" ]
87,010
<p>From browsing on this site and elsewhere, I've learned that serving websites as XHTML at present <a href="http://hixie.ch/advocacy/xhtml" rel="nofollow noreferrer">is considered harmful</a>.</p> <p>Delivering XHTML and serving it as <code>application/xhtml+xml</code> isn't supported by the majority of people browsing at present, delivering xhtml as <code>text/html</code> is at best a placebo for myself, and at worst a recipe for breaking sites usually when you least need it happening.</p> <p>So we end up back at html 4.01. If I instead serve my pages as html 4.01, is it possible to use SVG or any other XML-based language on the page?</p> <p>If so, how?</p>
[ { "answer_id": 194820, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 2, "selected": true, "text": "<object> <embed> <img> background-image data: data-*" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15479/" ]
87,021
<p>Given a moderately complex XML structure (dozens of elements, hundreds of attributes) with no XSD and a desire to create an object model, what's an elegant way to avoid writing boilerplate from_xml() and to_xml() methods? </p> <p>For instance, given:</p> <pre><code>&lt;Foo bar="1"&gt;&lt;Bat baz="blah"/&gt;&lt;/Foo&gt; </code></pre> <p>How do I avoid writing endless sequences of:</p> <pre><code>class Foo attr_reader :bar, :bat def from_xml(el) @bar = el.attributes['bar'] @bat = Bat.new() @bat.from_xml(XPath.first(el, "./bat") end etc... </code></pre> <p>I don't mind creating the object structure explicitly; it's the serialization that I'm just sure can be taken care of with some higher-level programming...</p> <hr> <p>I am not trying to save a line or two per class (by moving from_xml behavior into initializer or class method, etc.). I am looking for the "meta" solution that duplicates my mental process:</p> <p>"I know that every element is going to become a class name. I know that every XML attribute is going to be a field name. I know that the code to assign is just @#{attribute_name} = el.[#{attribute_name}] and then recurse into sub-elements. And reverse on to_xml."</p> <hr> <p>I agree with suggestion that a "builder" class plus XmlSimple seems the right path. XML -> Hash -> ? -> Object model (and Profit!)</p> <hr> <p>Update 2008-09-18 AM: Excellent suggestions from @Roman, @fatgeekuk, and @ScottKoon seem to have broken the problem open. I downloaded HPricot source to see how it solved the problem; key methods are clearly instance_variable_set and class_eval . irb work is very encouraging, am now moving towards implementation .... Very excited</p>
[ { "answer_id": 87079, "author": "Jim Deville", "author_id": 1591, "author_profile": "https://Stackoverflow.com/users/1591", "pm_score": 0, "selected": false, "text": "class Bar\n def initialize(el)\n self.from_xml(XPath.first(el, \"./bat\"))\n end\nend\n" }, { "answer_id": 91656, "author": "fatgeekuk", "author_id": 17518, "author_profile": "https://Stackoverflow.com/users/17518", "pm_score": 0, "selected": false, "text": "class XmlFoo\n def self.attr_accessor attributes = {}\n # need to add code here to maintain a list of the fields for the subclass, to be used in to_xml and from_xml\n attributes.each do |name, value|\n super name\n end\n end\n\n def to_xml options={}\n # need to use the hash of elements, and determine how to handle them by whether they are .kind_of?(XmlFoo)\n end\n\n def from_xml el\n end\nend\n class Second < XmlFoo\n attr_accessor :first_attr => String, :second_attr => Float\nend\n\nclass First < XmlFoo\n attr_accessor :normal_attribute => String, :sub_element => Second\nend\n" }, { "answer_id": 92046, "author": "Roman", "author_id": 12695, "author_profile": "https://Stackoverflow.com/users/12695", "pm_score": 1, "selected": false, "text": "obj.instance_variables.find {|v| obj.send(v.gsub(/^@/,'').to_sym).is_a?(Hash)}.each do |h|\n klass= eval(h.sub(/^@(.)/) { $1.upcase })\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10116/" ]
87,030
<p>Where can I download the JSSE and JCE source code for the latest release of Java? The source build available at <a href="https://jdk6.dev.java.net/" rel="noreferrer">https://jdk6.dev.java.net/</a> does not include the javax.crypto (JCE) packages nor the com.sun.net.ssl.internal (JSSE) packages.</p> <p>Not being able to debug these classes makes solving SSL issues incredibly difficult.</p>
[ { "answer_id": 87106, "author": "PW.", "author_id": 927, "author_profile": "https://Stackoverflow.com/users/927", "pm_score": 4, "selected": false, "text": "src/share/classes/javax/net\nsrc/share/classes/com/sun/net/ssl\nsrc/share/classes/sun/security/ssl\nsrc/share/classes/sun/net/www/protocol/https\n src/share/classes/javax/crypto\nsrc/share/classes/com/sun/crypto/provider\nsrc/share/classes/sun/security/pkcs11\nsrc/share/classes/sun/security/mscapi\n" }, { "answer_id": 4813158, "author": "jer", "author_id": 502524, "author_profile": "https://Stackoverflow.com/users/502524", "pm_score": 2, "selected": false, "text": "jar -xvf <filename> java -jar <filename>" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
87,096
<p>I really hate using STL containers because they make the debug version of my code run really slowly. What do other people use instead of STL that has reasonable performance for debug builds?</p> <p>I'm a game programmer and this has been a problem on many of the projects I've worked on. It's pretty hard to get 60 fps when you use STL container for everything.</p> <p>I use MSVC for most of my work.</p>
[ { "answer_id": 87265, "author": "rhinovirus", "author_id": 16715, "author_profile": "https://Stackoverflow.com/users/16715", "pm_score": 3, "selected": false, "text": "#define _SECURE_SCL 0\n#define _HAS_ITERATOR_DEBUGGING 0\n" }, { "answer_id": 87400, "author": "Jeff", "author_id": 16639, "author_profile": "https://Stackoverflow.com/users/16639", "pm_score": 5, "selected": false, "text": " debug release\nSTL 100 10\nEASTL 10 3\narray[i] 3 1\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16679/" ]
87,101
<p>What is a good way to select all or select no items in a listview without using:</p> <pre><code>foreach (ListViewItem item in listView1.Items) { item.Selected = true; } </code></pre> <p>or</p> <pre><code>foreach (ListViewItem item in listView1.Items) { item.Selected = false; } </code></pre> <p>I know the underlying Win32 listview common control supports <a href="http://msdn.microsoft.com/en-us/library/bb761196(VS.85).aspx" rel="nofollow noreferrer">LVM_SETITEMSTATE message</a> which you can use to set the selected state, and by passing -1 as the index it will apply to all items. I'd rather not be PInvoking messages to the control that happens to be behind the .NET Listview control (I don't want to be a bad developer and rely on undocumented behavior - for when they change it to a fully managed ListView class)</p> <h2>Bump</h2> <p><a href="https://stackoverflow.com/questions/87101/how-to-selectall-selectnone-in-net-2-0-listview/87209#87209">Pseudo Masochist</a> has the <strong>SelectNone</strong> case:</p> <pre><code>ListView1.SelectedItems.Clear(); </code></pre> <p>Now just need the <strong>SelectAll</strong> code</p>
[ { "answer_id": 87265, "author": "rhinovirus", "author_id": 16715, "author_profile": "https://Stackoverflow.com/users/16715", "pm_score": 3, "selected": false, "text": "#define _SECURE_SCL 0\n#define _HAS_ITERATOR_DEBUGGING 0\n" }, { "answer_id": 87400, "author": "Jeff", "author_id": 16639, "author_profile": "https://Stackoverflow.com/users/16639", "pm_score": 5, "selected": false, "text": " debug release\nSTL 100 10\nEASTL 10 3\narray[i] 3 1\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
87,107
<p>I've setup a new .net 2.0 website on IIS 7 under Win Server 2k8 and when browsing to a page it gives me a 404.17 error, claiming that the file (default.aspx in this case) appears to be a script but is being handled by the static file handler. It SOUNDS like the module mappings for ASP.Net got messed up, but they look fine in the configurations. Does anyone have a suggestion for correcting this error?</p>
[ { "answer_id": 87412, "author": "Jonathan Rupp", "author_id": 12502, "author_profile": "https://Stackoverflow.com/users/12502", "pm_score": 6, "selected": true, "text": "%windir%\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_regiis.exe -i \n" }, { "answer_id": 3461991, "author": "palswim", "author_id": 393280, "author_profile": "https://Stackoverflow.com/users/393280", "pm_score": 2, "selected": false, "text": "<remove name=\"WebServiceHandlerFactory-ISAPI-2.0\" />\n<add name=\"ScriptHandlerFactory\" verb=\"*\" path=\"*.asmx\" preCondition=\"integratedMode\" type=\"System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\" />\n" }, { "answer_id": 6832760, "author": "lior hakim", "author_id": 439612, "author_profile": "https://Stackoverflow.com/users/439612", "pm_score": 0, "selected": false, "text": "%windir%\\Microsoft.NET\\Framework64\\v2.0.50727\\aspnet_regiis.exe -i\n" }, { "answer_id": 13832308, "author": "ESiddiqui", "author_id": 1896552, "author_profile": "https://Stackoverflow.com/users/1896552", "pm_score": 3, "selected": false, "text": "cd %windir%\\Microsoft.NET\\Framework64/v4.0.30319\naspnet_regiis.exe -i\n" }, { "answer_id": 31297803, "author": "Chris", "author_id": 1308967, "author_profile": "https://Stackoverflow.com/users/1308967", "pm_score": 0, "selected": false, "text": "Dism /online /enable-feature /featurename:NetFx3 /All /Source:WindowsInstallers\\Win8\\sxs /LimitAccess\nDism /online /enable-feature /featurename:NetFx4 /All /Source:WindowsInstallers\\Win8\\sxs /LimitAccess\nDism /online /enable-feature /featurename:IIS-ISAPIExtensions /All /Source:WindowsInstallers\\Win8\\sxs /LimitAccess\nDism /online /enable-feature /featurename:IIS-ISAPIFilter /All /Source:WindowsInstallers\\Win8\\sxs /LimitAccess\nDism /online /enable-feature /featurename:IIS-ServerSideIncludes /All /Source:WindowsInstallers\\Win8\\sxs /LimitAccess\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16729/" ]
87,134
<p>I'm making a WinForms app with a ListView set to detail so that several columns can be displayed.</p> <p>I'd like for this list to scroll when the mouse is over the control and the user uses the mouse scroll wheel. Right now, scrolling only happens when the ListView has focus.</p> <p>How can I make the ListView scroll even when it doesn't have focus?</p>
[ { "answer_id": 25816903, "author": "Chris W", "author_id": 890258, "author_profile": "https://Stackoverflow.com/users/890258", "pm_score": 3, "selected": false, "text": "public class FormContainingListView : Form, IMessageFilter\n{\n public FormContainingListView()\n {\n // ...\n Application.AddMessageFilter(this);\n }\n\n #region mouse wheel without focus\n\n // P/Invoke declarations\n [DllImport(\"user32.dll\")]\n private static extern IntPtr WindowFromPoint(Point pt);\n [DllImport(\"user32.dll\")]\n private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);\n\n public bool PreFilterMessage(ref Message m)\n {\n if (m.Msg == 0x20a)\n {\n // WM_MOUSEWHEEL, find the control at screen position m.LParam\n Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);\n IntPtr hWnd = WindowFromPoint(pos);\n if (hWnd != IntPtr.Zero && hWnd != m.HWnd && System.Windows.Forms.Control.FromHandle(hWnd) != null)\n {\n SendMessage(hWnd, m.Msg, m.WParam, m.LParam);\n return true;\n }\n }\n return false;\n }\n\n #endregion\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6151/" ]
87,177
<p>I had data in XML that had line feeds, spaces, and tabs that I wanted to preserve in the output HTML (so I couldn't use &lt;p&gt;) but I also wanted the lines to wrap when the side of the screen was reached (so I couldn't use &lt;pre&gt;).</p>
[ { "answer_id": 92703, "author": "JeniT", "author_id": 6739, "author_profile": "https://Stackoverflow.com/users/6739", "pm_score": 1, "selected": false, "text": "<br> <xsl:template name=\"replace-spaces\">\n <xsl:param name=\"text\" />\n <xsl:choose>\n <xsl:when test=\"contains($text, ' ')\">\n <xsl:call-template name=\"replace-spaces\">\n <xsl:with-param name=\"text\" select=\"substring-before($text, ' ')\"/>\n </xsl:call-template>\n <xsl:text>&#xA0;&#xA0;</xsl:text>\n <xsl:call-template name=\"replace-spaces\">\n <xsl:with-param name=\"text\" select=\"substring-before($text, ' ')\" />\n </xsl:call-template>\n </xsl:when>\n <xsl:when test=\"contains($text, '&#x9;')\">\n <xsl:call-template name=\"replace-spaces\">\n <xsl:with-param name=\"text\" select=\"substring-before($text, '&#x9;')\"/>\n </xsl:call-template>\n <xsl:text>&#xA0;&#xA0;&#xA0;&#xA0;</xsl:text>\n <xsl:call-template name=\"replace-spaces\">\n <xsl:with-param name=\"text\" select=\"substring-before($text, '&#x9;')\" />\n </xsl:call-template>\n </xsl:when>\n <xsl:when test=\"contains($text, '&#xA;')\">\n <xsl:call-template name=\"replace-spaces\">\n <xsl:with-param name=\"text\" select=\"substring-before($text, '&#xA;')\" />\n </xsl:call-template>\n <br />\n <xsl:call-template name=\"replace-spaces\">\n <xsl:with-param name=\"text\" select=\"substring-after($text, '&#xA;')\" />\n </xsl:call-template>\n </xsl:when>\n <xsl:otherwise>\n <xsl:value-of select=\"$text\" />\n </xsl:otherwise>\n </xsl:choose>\n</xsl:template>\n <xsl:analyze-string>" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6770/" ]
87,184
<p>There seems to be no good way to localize a WPF application. MSDN seems to think that littering my XAML with <code>x:Uid</code>'s, generating CSV files, and then generating new assemblies (using their sample code!) is the answer. Worse, this process doesn't address how to localize images, binary blobs (say, PDF files), or strings that are embedded in code.</p> <p>So, how might you localize an application that:</p> <ol> <li>Contains several assemblies</li> <li>Contains images and other binary blobs (eg: PDF docs) that need to be localized</li> <li>Has string data that isn't in XAML (eg: <code>MessageBox.Show("Hello World");</code>)</li> </ol>
[ { "answer_id": 87478, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "http://blog.taggersoft.com/2008/07/wpf-application-localization-pattern_29.html" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16742/" ]
87,190
<p>Does anyone know of a .NET library that will process HTML e-mails and can be used to trim out the reply-chain? It needs to be able to accept HTML -or- text mails and then trim out everything but the actual response, removing the trail of messages that are not original content. I don't expect it to be able to handle responseswhen they're interleaved into the previous mail ("responses in-line") - that case can fail.</p> <p>We have a home-built one based on SgmlReader and a series of XSL transforms, but it requires constant maintenance to deal with new e-mail clients. I'd like to find one I can buy... :)</p> <p>Thanks, Steve</p>
[ { "answer_id": 87478, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "http://blog.taggersoft.com/2008/07/wpf-application-localization-pattern_29.html" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7104/" ]
87,192
<p>After reading <a href="http://www.colder.ch/news/08-24-2007/28/late-static-bindings-expl.html" rel="noreferrer">this description</a> of late static binding (LSB) I see pretty clearly what is going on. Now, under which sorts of circumstances might that be most useful or needed?</p>
[ { "answer_id": 87457, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "class User extends ActiveRecord User::find(1) ActiveRecord::find() find() User find() ActiveRecord self ActiveRecord" }, { "answer_id": 87584, "author": "Adam Franco", "author_id": 15872, "author_profile": "https://Stackoverflow.com/users/15872", "pm_score": 3, "selected": false, "text": "class DateAndTime {\n\n public static function now() {\n $class = static::myClass();\n $obj = new $class;\n $obj->setSeconds(time());\n return $obj;\n }\n\n public static function yesterday() {\n $class = static::myClass();\n $obj = new $class;\n $obj->setSeconds(time() - 86400);\n return $obj;\n }\n\n protected static function myClass () {\n return 'DateAndTime';\n }\n}\n\nclass Timestamp extends DateAndTime {\n\n protected static function myClass () {\n return 'Timestamp';\n }\n}\n\n\n// Usage:\n$date = DateAndTime::now();\n$timestamp = Timestamp::now();\n\n$date2 = DateAndTime::yesterday();\n$timestamp2 = Timestamp::yesterday();\n class DateAndTime {\n\n public static function now($class = 'DateAndTime') {\n $obj = new $class;\n $obj->setSeconds(time());\n return $obj;\n }\n\n public static function yesterday($class = 'DateAndTime') {\n $obj = new $class;\n $obj->setSeconds(time() - 86400);\n return $obj;\n }\n\n}\n\nclass Timestamp extends DateAndTime {\n\n public static function now($class = 'Timestamp') {\n return self::now($class);\n }\n\n public static function yesterday($class = 'Timestamp') {\n return self::yesterday($class);\n }\n\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11252/" ]
87,200
<p>I have finally started messing around with creating some apps that work with RESTful web interfaces, however, I am concerned that I am hammering their servers every time I hit F5 to run a series of tests..</p> <p>Basically, I need to get a series of web responses so I can test I am parsing the varying responses correctly, rather than hit their servers every time, I thought I could do this once, save the XML and then work locally.</p> <p>However, I don't see how I can &quot;mock&quot; a WebResponse, since (AFAIK) they can only be instantiated by <strong>WebRequest.GetResponse</strong></p> <p>How do you guys go about mocking this sort of thing? Do you? I just really don't like the fact I am hammering their servers :S I dont want to change the code <em>too</em> much, but I expect there is a elegant way of doing this..</p> <h2>Update Following Accept</h2> <p>Will's answer was the slap in the face I needed, I knew I was missing a fundamental point!</p> <ul> <li>Create an Interface that will return a proxy object which represents the XML.</li> <li>Implement the interface twice, one that uses WebRequest, the other that returns static &quot;responses&quot;.</li> <li>The interface implmentation then either instantiates the return type based on the response, or the static XML.</li> <li>You can then pass the required class when testing or at production to the service layer.</li> </ul> <p>Once I have the code knocked up, I'll paste some samples.</p>
[ { "answer_id": 707607, "author": "dr. evil", "author_id": 40322, "author_profile": "https://Stackoverflow.com/users/40322", "pm_score": 0, "selected": false, "text": "using System;\nusing System.IO;\nusing System.Net;\nusing NUnit.Framework;\nusing TypeMock;\n\nnamespace MockHttpWebRequest\n{\n public class LibraryClass\n {\n public string GetGoogleHomePage()\n {\n HttpWebRequest request = (HttpWebRequest)WebRequest.Create(\"http://www.google.com\");\n HttpWebResponse response = (HttpWebResponse)request.GetResponse();\n using (StreamReader reader = new StreamReader(response.GetResponseStream()))\n {\n return reader.ReadToEnd();\n }\n }\n }\n\n [TestFixture]\n [VerifyMocks]\n public class UnitTests\n {\n private Stream responseStream = null;\n private const string ExpectedResponseContent = \"Content from mocked response.\";\n\n [SetUp]\n public void SetUp()\n {\n System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();\n byte[] contentAsBytes = encoding.GetBytes(ExpectedResponseContent);\n this.responseStream = new MemoryStream();\n this.responseStream.Write(contentAsBytes, 0, contentAsBytes.Length);\n this.responseStream.Position = 0;\n }\n\n [TearDown]\n public void TearDown()\n {\n if (responseStream != null)\n {\n responseStream.Dispose();\n responseStream = null;\n }\n }\n\n [Test(Description = \"Mocks a web request using natural mocks.\")]\n public void NaturalMocks()\n {\n HttpWebRequest mockRequest = RecorderManager.CreateMockedObject<HttpWebRequest>(Constructor.Mocked);\n HttpWebResponse mockResponse = RecorderManager.CreateMockedObject<HttpWebResponse>(Constructor.Mocked);\n using (RecordExpectations recorder = RecorderManager.StartRecording())\n {\n WebRequest.Create(\"http://www.google.com\");\n recorder.CheckArguments();\n recorder.Return(mockRequest);\n\n mockRequest.GetResponse();\n recorder.Return(mockResponse);\n\n mockResponse.GetResponseStream();\n recorder.Return(this.responseStream);\n }\n\n LibraryClass testObject = new LibraryClass();\n string result = testObject.GetGoogleHomePage();\n Assert.AreEqual(ExpectedResponseContent, result);\n }\n\n [Test(Description = \"Mocks a web request using reflective mocks.\")]\n public void ReflectiveMocks()\n {\n Mock<HttpWebRequest> mockRequest = MockManager.Mock<HttpWebRequest>(Constructor.Mocked);\n MockObject<HttpWebResponse> mockResponse = MockManager.MockObject<HttpWebResponse>(Constructor.Mocked);\n mockResponse.ExpectAndReturn(\"GetResponseStream\", this.responseStream);\n mockRequest.ExpectAndReturn(\"GetResponse\", mockResponse.Object);\n\n LibraryClass testObject = new LibraryClass();\n string result = testObject.GetGoogleHomePage();\n Assert.AreEqual(ExpectedResponseContent, result);\n }\n }\n}\n" }, { "answer_id": 1586128, "author": "Richard Willis", "author_id": 192122, "author_profile": "https://Stackoverflow.com/users/192122", "pm_score": 7, "selected": true, "text": "WebRequest.RegisterPrefix WebRequest.Create IWebRequestCreate Create WebRequest WebRequest" }, { "answer_id": 5339226, "author": "Simon Parsons", "author_id": 664343, "author_profile": "https://Stackoverflow.com/users/664343", "pm_score": 2, "selected": false, "text": " [TestMethod]\n [HostType(\"Moles\")]\n [Description(\"Tests that the default scraper returns the correct result\")]\n public void Scrape_KnownUrl_ReturnsExpectedValue()\n {\n var mockedWebResponse = new MHttpWebResponse();\n\n MHttpWebRequest.AllInstances.GetResponse = (x) =>\n {\n return mockedWebResponse;\n };\n\n mockedWebResponse.StatusCodeGet = () => { return HttpStatusCode.OK; };\n mockedWebResponse.ResponseUriGet = () => { return new Uri(\"http://www.google.co.uk/someRedirect.aspx\"); };\n mockedWebResponse.ContentTypeGet = () => { return \"testHttpResponse\"; }; \n\n var mockedResponse = \"<html> \\r\\n\" +\n \" <head></head> \\r\\n\" +\n \" <body> \\r\\n\" +\n \" <h1>Hello World</h1> \\r\\n\" +\n \" </body> \\r\\n\" +\n \"</html>\";\n\n var s = new MemoryStream();\n var sw = new StreamWriter(s);\n\n sw.Write(mockedResponse);\n sw.Flush();\n\n s.Seek(0, SeekOrigin.Begin);\n\n mockedWebResponse.GetResponseStream = () => s;\n\n var scraper = new DefaultScraper();\n var retVal = scraper.Scrape(\"http://www.google.co.uk\");\n\n Assert.AreEqual(mockedResponse, retVal.Content, \"Should have returned the test html response\");\n Assert.AreEqual(\"http://www.google.co.uk/someRedirect.aspx\", retVal.FinalUrl, \"The finalUrl does not correctly represent the redirection that took place.\");\n }\n" }, { "answer_id": 10882731, "author": "escape-llc", "author_id": 650049, "author_profile": "https://Stackoverflow.com/users/650049", "pm_score": 4, "selected": false, "text": "WebRequest IWebRequestCreate WebRequest WebResponse WebException class WebRequestFailedCreate : IWebRequestCreate {\n HttpStatusCode status;\n String statusDescription;\n public WebRequestFailedCreate(HttpStatusCode hsc, String sd) {\n status = hsc;\n statusDescription = sd;\n }\n #region IWebRequestCreate Members\n public WebRequest Create(Uri uri) {\n return new WebRequestFailed(uri, status, statusDescription);\n }\n #endregion\n}\nclass WebRequestFailed : WebRequest {\n HttpStatusCode status;\n String statusDescription;\n Uri itemUri;\n public WebRequestFailed(Uri uri, HttpStatusCode status, String statusDescription) {\n this.itemUri = uri;\n this.status = status;\n this.statusDescription = statusDescription;\n }\n WebException GetException() {\n SerializationInfo si = new SerializationInfo(typeof(HttpWebResponse), new System.Runtime.Serialization.FormatterConverter());\n StreamingContext sc = new StreamingContext();\n WebHeaderCollection headers = new WebHeaderCollection();\n si.AddValue(\"m_HttpResponseHeaders\", headers);\n si.AddValue(\"m_Uri\", itemUri);\n si.AddValue(\"m_Certificate\", null);\n si.AddValue(\"m_Version\", HttpVersion.Version11);\n si.AddValue(\"m_StatusCode\", status);\n si.AddValue(\"m_ContentLength\", 0);\n si.AddValue(\"m_Verb\", \"GET\");\n si.AddValue(\"m_StatusDescription\", statusDescription);\n si.AddValue(\"m_MediaType\", null);\n WebResponseFailed wr = new WebResponseFailed(si, sc);\n Exception inner = new Exception(statusDescription);\n return new WebException(\"This request failed\", inner, WebExceptionStatus.ProtocolError, wr);\n }\n public override WebResponse GetResponse() {\n throw GetException();\n }\n public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state) {\n Task<WebResponse> f = Task<WebResponse>.Factory.StartNew (\n _ =>\n {\n throw GetException();\n },\n state\n );\n if (callback != null) f.ContinueWith((res) => callback(f));\n return f;\n }\n public override WebResponse EndGetResponse(IAsyncResult asyncResult) {\n return ((Task<WebResponse>)asyncResult).Result;\n }\n\n}\nclass WebResponseFailed : HttpWebResponse {\n public WebResponseFailed(SerializationInfo serializationInfo, StreamingContext streamingContext)\n : base(serializationInfo, streamingContext) {\n }\n}\n HttpWebResponse GetException() StatusCode SerializaionInfo HttpWebResponse AddValue() [TestMethod, ExpectedException(typeof(WebException))]\n public void WebRequestFailedThrowsWebException() {\n string TestURIProtocol = TestContext.TestName;\n var ResourcesBaseURL = TestURIProtocol + \"://resources/\";\n var ContainerBaseURL = ResourcesBaseURL + \"container\" + \"/\";\n WebRequest.RegisterPrefix(TestURIProtocol, new WebRequestFailedCreate(HttpStatusCode.InternalServerError, \"This request failed on purpose.\"));\n WebRequest wr = WebRequest.Create(ContainerBaseURL);\n try {\n WebResponse wrsp = wr.GetResponse();\n using (wrsp) {\n Assert.Fail(\"WebRequest.GetResponse() Should not have succeeded.\");\n }\n }\n catch (WebException we) {\n Assert.IsInstanceOfType(we.Response, typeof(HttpWebResponse));\n Assert.AreEqual(HttpStatusCode.InternalServerError, (we.Response as HttpWebResponse).StatusCode, \"Status Code failed\");\n throw we;\n }\n }\n" }, { "answer_id": 71235523, "author": "ozba", "author_id": 237461, "author_profile": "https://Stackoverflow.com/users/237461", "pm_score": 0, "selected": false, "text": " var httpWebResponse = Substitute.For<HttpWebResponse>();\n httpWebResponse.StatusCode.Returns(HttpStatusCode.NotFound);\n httpWebResponse.StatusDescription.Returns(\"Not Found\");\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
87,220
<p>How does gcc implement stack unrolling for C++ exceptions on linux? In particular, how does it know which destructors to call when unrolling a frame (i.e., what kind of information is stored and where is it stored)?</p>
[ { "answer_id": 4506050, "author": "Electron", "author_id": 550759, "author_profile": "https://Stackoverflow.com/users/550759", "pm_score": 5, "selected": true, "text": ".eh_frame .gcc_except_table .eh_frame .debug_frame -g .gcc_except_table" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16480/" ]
87,221
<p><a href="https://stackoverflow.com/questions/2262/aspnet-url-rewriting">So this post</a> talked about how to actually implement url rewriting in an ASP.NET application to get "friendly urls". That works perfect and it is great for sending a user to a specific page, but does anyone know of a good solution for creating "Friendly" URLs inside your code when using one of the tools referenced?</p> <p>For example listing a link inside of an asp.net control as ~/mypage.aspx?product=12 when a rewrite rule exists would be an issue as then you are linking to content in two different ways.</p> <p>I'm familiar with using DotNetNuke and FriendlyUrl's where there is a "NavigateUrl" method that will get the friendly Url code from the re-writer but I'm not finding examples of how to do this with UrlRewriting.net or the other solutions out there. </p> <p>Ideally I'd like to be able to get something like this.</p> <pre><code>string friendlyUrl = GetFriendlyUrl("~/MyUnfriendlyPage.aspx?myid=13"); </code></pre> <p><strong>EDIT:</strong> I am looking for a generic solution, not something that I have to implement for every page in my site, but potentially something that can match against the rules in the opposite direction.</p>
[ { "answer_id": 87263, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 0, "selected": false, "text": "public class UrlBuilder\n{\n public static string BuildProductUrl(int id)\n {\n if (true) // replace with logic to determine if URL rewriting is enabled\n {\n return string.Format(\"~/Product/{0}\", id);\n }\n else\n {\n return string.Format(\"~/product.aspx?id={0}\", id);\n }\n }\n}\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13279/" ]
87,222
<p>How do i represent CRLF using Hex in C#?</p>
[ { "answer_id": 87312, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 7, "selected": true, "text": " \"\\x0d\\x0a\"\n" }, { "answer_id": 27848240, "author": "Anonymous", "author_id": 4434369, "author_profile": "https://Stackoverflow.com/users/4434369", "pm_score": 2, "selected": false, "text": "x0d x0a (\\r\\n) \n x0a (\\n)\n x0d x0a x0a x0a x0d x0a" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
87,224
<p>It is obviosly some Perl extensions. Perl version is 5.8.8.</p> <p>I found Error.pm, but now I'm looking for Core.pm. </p> <p>While we're at it: how do you guys search for those modules. I tried Google, but that didn't help much. Thanks.</p> <hr> <p>And finally, after I built everything, running: </p> <pre><code>./Build install </code></pre> <p>gives me:</p> <pre><code>Running make install-lib /bin/ginstall -c -d /usr/lib/perl5/site_perl/5.8.8/i486-linux-thread-multi/Alien/SVN --prefix=/usr /bin/ginstall: unrecognized option `--prefix=/usr' Try `/bin/ginstall --help' for more information. make: *** [install-fsmod-lib] Error 1 installing libs failed at inc/My/SVN/Builder.pm line 165. </code></pre> <p>Looks like Slackware's 'ginstall' really does not have that option. I think I'm going to Google a little bit now, to see how to get around this.</p>
[ { "answer_id": 87311, "author": "Michael Carman", "author_id": 8233, "author_profile": "https://Stackoverflow.com/users/8233", "pm_score": 2, "selected": true, "text": "perl Makefile.pl\nmake\nmake test\nmake install\n" }, { "answer_id": 87768, "author": "cjm", "author_id": 8355, "author_profile": "https://Stackoverflow.com/users/8355", "pm_score": 2, "selected": false, "text": "Base class package \"Module::Build\" is empty.\n (Perhaps you need to 'use' the module which defines that package first.)\n at inc/My/SVN/Builder.pm line 5\nBEGIN failed--compilation aborted at inc/My/SVN/Builder.pm line 5.\nCompilation failed in require at Build.PL line 6.\nBEGIN failed--compilation aborted at Build.PL line 6.\n perl Build.PL\n./Build\n./Build test\n./Build install\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14690/" ]
87,262
<p>I need to find the frequency of a sample, stored (in vb) as an array of byte. Sample is a sine wave, known frequency, so I can check), but the numbers are a bit odd, and my maths-foo is weak. Full range of values 0-255. 99% of numbers are in range 235 to 245, but there are some outliers down to 0 and 1, and up to 255 in the remaining 1%. How do I normalise this to remove outliers, (calculating the 235-245 interval as it may change with different samples), and how do I then calculate zero-crossings to get the frequency? Apologies if this description is rubbish!</p>
[ { "answer_id": 87613, "author": "AShelly", "author_id": 10396, "author_profile": "https://Stackoverflow.com/users/10396", "pm_score": 4, "selected": true, "text": "for (i=lower=0;i< N*(X/100); lower++)\n i+=count[lower];\n//repeat in other direction for upper\n A[i] = 255*(A[i]-lower)/(upper-lower)-128\n" }, { "answer_id": 87824, "author": "cjanssen", "author_id": 2950, "author_profile": "https://Stackoverflow.com/users/2950", "pm_score": 2, "selected": false, "text": "x[n] = A*sin(f*n + phi) + B + N[n]\n y[n] = median3(x[n])\n" }, { "answer_id": 88719, "author": "Brendan", "author_id": 199, "author_profile": "https://Stackoverflow.com/users/199", "pm_score": 1, "selected": false, "text": "a*sin(b*x-c) 2*pi/b" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2135219/" ]
87,290
<p>Although I don't have an iPhone to test this out, my colleague told me that embedded media files such as the one in the snippet below, only works when the iphone is connected over the WLAN connection or 3G, and does not work when connecting via GPRS.</p> <pre><code>&lt;html&gt;&lt;body&gt; &lt;object data="http://joliclic.free.fr/html/object-tag/en/data/test.mp3" type="audio/mpeg"&gt; &lt;p&gt;alternate text&lt;/p&gt; &lt;/object&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>Is there an example URL with a media file, that will play in an iPhone browser when the iphone connects using GPRS (not 3G)?</p>
[ { "answer_id": 596046, "author": "Diogenes", "author_id": 69528, "author_profile": "https://Stackoverflow.com/users/69528", "pm_score": 1, "selected": false, "text": "<div class=\"music\">\n <p>Pachelbel's Canon</p>\n <!--[if !IE]>-->\n <object id=\"Cannon\" type=\"audio/mpeg\" data=\"http://calgarydj.ca/sound%20files/Pachebels%20Cannon.mp3\" width=\"250\" height=\"16\">\n <param name=\"autoplay\" value=\"false\" />\n <param name=\"src\" value=\"http://calgarydj.ca/sound%20files/Pachebels%20Cannon.mp3\" />\n <!--<![endif]-->\n <object id=\"Cannon\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"250\" height=\"60\">\n <param name=\"autostart\" value=\"false\" />\n\n <param name=\"url\" value=\"http://calgarydj.ca/sound%20files/Pachebels%20Cannon.mp3\" />\n <param name=\"showcontrols\" value=\"true\" />\n <param name=\"volume\" value=\"100\" />\n <!--[if !IE]>--></object><!--<![endif]-->\n </object>\n</div><!-- end of control -->\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6225/" ]
87,299
<p>I want to ditch my current editor. I feel I need something else. That do not expose my hands to the risk of RSI. I need to see why I should change editor. And it would be nice to believe, that I will be coding when I'm 80 years old.</p> <p>All the big guys out there are using Vim. The only Emacs guy I know are RMS. Paul Graham is a Vi dude. </p>
[ { "answer_id": 87321, "author": "Max Cantor", "author_id": 16034, "author_profile": "https://Stackoverflow.com/users/16034", "pm_score": 4, "selected": false, "text": "*\n" }, { "answer_id": 87341, "author": "Linulin", "author_id": 12481, "author_profile": "https://Stackoverflow.com/users/12481", "pm_score": 6, "selected": true, "text": "." }, { "answer_id": 101726, "author": "Zsolt Botykai", "author_id": 11621, "author_profile": "https://Stackoverflow.com/users/11621", "pm_score": 2, "selected": false, "text": "\\_." }, { "answer_id": 25291142, "author": "user210757", "author_id": 210757, "author_profile": "https://Stackoverflow.com/users/210757", "pm_score": -1, "selected": false, "text": "\\v\n" } ]
2008/09/17
[ "https://Stackoverflow.com/questions/87299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15054/" ]