qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
250,289
<p>Obviously (methinks), creating an index on a <code>BIT</code> column is unnecessary. However, if you had a column that you need to search in which every value is likely unique, like <code>BlogPost</code> or <code>StreetAddress</code> or something, then an index seems appropriate (again, methinks).</p> <p>But what's the cutoff? What if you expect 10,000 rows and you'll have about 20 unique values among them. Should an index be created?</p> <p>Thanks in advance.</p>
[ { "answer_id": 250338, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 1, "selected": false, "text": "BIT SELECT foo.Name FROM foo WHERE foo.Active = 1\n" }, { "answer_id": 18809883, "author": "Ardalan Shahgholi", "author_id": 2063547, "author_profile": "https://Stackoverflow.com/users/2063547", "pm_score": 0, "selected": false, "text": "USE master; \nGo\nSELECT d.database_id,\n d.object_id,\n d.index_handle,\n d.equality_columns,\n d.inequality_columns,\n d.included_columns,\n d.statement AS fully_qualified_object,\n gs.*\nFROM sys.dm_db_missing_index_groups g\nJOIN sys.dm_db_missing_index_group_stats gs ON gs.group_handle = g.index_group_handle\nJOIN sys.dm_db_missing_index_details d ON g.index_handle = d.index_handle\n\nGo\n\nSELECT mig.index_group_handle,\n mid.index_handle,\n migs.avg_total_user_cost AS AvgTotalUserCostThatCouldbeReduced,\n migs.avg_user_impact AS AvgPercentageBenefit,\n 'CREATE INDEX missing_index_' + CONVERT (varchar, mig.index_group_handle)\n + '_' + CONVERT (varchar, mid.index_handle)\n + ' ON ' + mid.statement\n + ' (' + ISNULL (mid.equality_columns,'')\n + CASE\n WHEN mid.equality_columns IS NOT NULL AND mid.inequality_columns\n IS NOT NULL THEN ','\n ELSE ''\n END\n + ISNULL (mid.inequality_columns, '')\n + ')'\n + ISNULL (' INCLUDE (' + mid.included_columns + ')', '') AS create_index_statement\nFROM sys.dm_db_missing_index_groups mig \nINNER JOIN sys.dm_db_missing_index_group_stats migs ON migs.group_handle = mig.index_group_handle\nINNER JOIN sys.dm_db_missing_index_details mid ON mig.index_handle = mid.index_handle\nOrder By migs.avg_user_impact Desc\n" }, { "answer_id": 26555525, "author": "LCJ", "author_id": 696627, "author_profile": "https://Stackoverflow.com/users/696627", "pm_score": 0, "selected": false, "text": "DMV SELECT\n migs.avg_total_user_cost * (migs.avg_user_impact / 100.0) * (migs.user_seeks + migs.user_scans) AS improvement_measure,\n 'CREATE INDEX [missing_index_' + CONVERT (varchar, mig.index_group_handle) + '_' + CONVERT (varchar, mid.index_handle)\n + '_' + LEFT (PARSENAME(mid.statement, 1), 32) + ']'\n + ' ON ' + mid.statement\n + ' (' + ISNULL (mid.equality_columns,'')\n + CASE WHEN mid.equality_columns IS NOT NULL AND mid.inequality_columns IS NOT NULL THEN ',' ELSE '' END\n + ISNULL (mid.inequality_columns, '')\n + ')'\n + ISNULL (' INCLUDE (' + mid.included_columns + ')', '') AS create_index_statement,\n migs.*, mid.database_id, mid.[object_id]\nFROM sys.dm_db_missing_index_groups mig\nINNER JOIN sys.dm_db_missing_index_group_stats migs ON migs.group_handle = mig.index_group_handle\nINNER JOIN sys.dm_db_missing_index_details mid ON mig.index_handle = mid.index_handle\nWHERE migs.avg_total_user_cost * (migs.avg_user_impact / 100.0) * (migs.user_seeks + migs.user_scans) > 10\nORDER BY migs.avg_total_user_cost * migs.avg_user_impact * (migs.user_seeks + migs.user_scans) DESC\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32382/" ]
250,304
<p>A VBScript cannot edit the registry by default on Vista. How do I get elevation (even if the user has to do something when they run the script) so that the script can edit the registry?</p> <p>The error is:</p> <pre><code>--------------------------- Windows Script Host --------------------------- Script: blah blah blah.vbs Line: 6 Char: 1 Error: Permission denied Code: 800A0046 Source: Microsoft VBScript runtime error --------------------------- OK --------------------------- </code></pre>
[ { "answer_id": 250343, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 0, "selected": false, "text": "regedit.exe" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1490/" ]
250,324
<p>I am wondering what the best way is using php to obtain a list of all the rows in the database, and when clicking on a row show the information in more detail, such as a related image etc.</p> <p>Should I use frames to do this? Are there good examples of this somewhere?</p> <p>Edit:</p> <p>I need much simpler instructions, as I am not a programmer and am just starting out. Can any links or examples be recommended?</p>
[ { "answer_id": 250331, "author": "changelog", "author_id": 5646, "author_profile": "https://Stackoverflow.com/users/5646", "pm_score": 0, "selected": false, "text": "$_GET['id']" }, { "answer_id": 251880, "author": "kevtrout", "author_id": 1149, "author_profile": "https://Stackoverflow.com/users/1149", "pm_score": 3, "selected": true, "text": "mysql_connect() mysql_select_db() msyql_query() $query=mysql_query(\"select * from table_name\");\n while($row=mysql_fetch_assoc($query)){\n extract($row);\n echo $name of field 1.\": \".$name of field 2;\n }\n echo \"<a href=\\\"http://addresstomoreinfo.php?image_id=\".$image_id.\\\">\".$name \n of field 1.\": \".$name of field 2.\"</a>\";\n $var=$_GET['image_id'];" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
250,357
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p> <p>For example:</p> <pre> Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." </pre> <p>I'm looking for a way to accomplish the "smart" truncate from above.</p>
[ { "answer_id": 250373, "author": "Adam", "author_id": 30084, "author_profile": "https://Stackoverflow.com/users/30084", "pm_score": 7, "selected": true, "text": "def smart_truncate(content, length=100, suffix='...'):\n if len(content) <= length:\n return content\n else:\n return ' '.join(content[:length+1].split(' ')[0:-1]) + suffix\n" }, { "answer_id": 250406, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 6, "selected": false, "text": "return content[:length].rsplit(' ', 1)[0]+suffix\n" }, { "answer_id": 250409, "author": "Vebjorn Ljosa", "author_id": 17498, "author_profile": "https://Stackoverflow.com/users/17498", "pm_score": 2, "selected": false, "text": "def smart_truncate(s, width):\n if s[width].isspace():\n return s[0:width];\n else:\n return s[0:width].rsplit(None, 1)[0]\n >>> smart_truncate('The quick brown fox jumped over the lazy dog.', 23) + \"...\"\n'The quick brown fox...'\n" }, { "answer_id": 250471, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 3, "selected": false, "text": "def smart_truncate1(text, max_length=100, suffix='...'):\n \"\"\"Returns a string of at most `max_length` characters, cutting\n only at word-boundaries. If the string was truncated, `suffix`\n will be appended.\n \"\"\"\n\n if len(text) > max_length:\n pattern = r'^(.{0,%d}\\S)\\s.*' % (max_length-len(suffix)-1)\n return re.sub(pattern, r'\\1' + suffix, text)\n else:\n return text\n def smart_truncate2(text, min_length=100, suffix='...'):\n \"\"\"If the `text` is more than `min_length` characters long,\n it will be cut at the next word-boundary and `suffix`will\n be appended.\n \"\"\"\n\n pattern = r'^(.{%d,}?\\S)\\s.*' % (min_length-1)\n return re.sub(pattern, r'\\1' + suffix, text)\n def smart_truncate3(text, length=100, suffix='...'):\n \"\"\"Truncates `text`, on a word boundary, as close to\n the target length it can come.\n \"\"\"\n\n slen = len(suffix)\n pattern = r'^(.{0,%d}\\S)\\s+\\S+' % (length-slen-1)\n if len(text) > length:\n match = re.match(pattern, text)\n if match:\n length0 = match.end(0)\n length1 = match.end(1)\n if abs(length0+slen-length) < abs(length1+slen-length):\n return match.group(0) + suffix\n else:\n return match.group(1) + suffix\n return text\n" }, { "answer_id": 250684, "author": "Brian", "author_id": 9493, "author_profile": "https://Stackoverflow.com/users/9493", "pm_score": 4, "selected": false, "text": "def truncate(text, max_size):\n if len(text) <= max_size:\n return text\n return textwrap.wrap(text, max_size-3)[0] + \"...\"\n lines = textwrap.wrap(text, max_size-3, break_long_words=False)\n return lines[0] + (\"...\" if len(lines)>1 else \"\")\n" }, { "answer_id": 20821663, "author": "Anthony", "author_id": 203204, "author_profile": "https://Stackoverflow.com/users/203204", "pm_score": 3, "selected": false, "text": ">>> import textwrap\n>>> textwrap.wrap('The quick brown fox jumps over the lazy dog', 12)\n['The quick', 'brown fox', 'jumps over', 'the lazy dog']\n" }, { "answer_id": 47296254, "author": "marcanuy", "author_id": 1165509, "author_profile": "https://Stackoverflow.com/users/1165509", "pm_score": 2, "selected": false, "text": ">>> import textwrap\n>>> original = \"This is really awesome.\"\n>>> textwrap.shorten(original, width=20, placeholder=\"...\")\n'This is really...'\n" }, { "answer_id": 65020386, "author": "Jorge Barata", "author_id": 959819, "author_profile": "https://Stackoverflow.com/users/959819", "pm_score": 0, "selected": false, "text": "def truncate(description, max_len=140, suffix='…'): \n description = description.strip()\n if len(description) <= max_len:\n return description\n new_description = ''\n for word in description.split(' '):\n tmp_description = new_description + word\n if len(tmp_description) <= max_len-len(suffix):\n new_description = tmp_description + ' '\n else:\n new_description = new_description.strip() + suffix\n break\n return new_description\n" }, { "answer_id": 65836694, "author": "CPBL", "author_id": 1159005, "author_profile": "https://Stackoverflow.com/users/1159005", "pm_score": 0, "selected": false, "text": "def smart_truncate_by_sentence(content, length=100, suffix='...',):\n if not isinstance(content,str): return content\n if len(content) <= length:\n return content\n else:\n sentences=content.split('.')\n cs=np.cumsum([len(s) for s in sentences])\n n = max(1, len(cs[cs<length]) )\n return '.'.join(sentences[:n])+ '. ...'*(n<len(sentences))\n" }, { "answer_id": 70512067, "author": "Claud", "author_id": 4844186, "author_profile": "https://Stackoverflow.com/users/4844186", "pm_score": 0, "selected": false, "text": "string trim(string s, int k) {\n if (s.size()<=k) return s;\n while(k>=0 && s[k]!=' ')\n k--;\n if (k<0) return \"\";\n string res=s.substr(0, k+1);\n while(res.size() && (res.back()==' '))\n res.pop_back();\n return res; \n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24998/" ]
250,369
<p>We are ready to start a brand new project at work, no legacy code. We did use Subsonic in the past and we pretty happy with it. But that was before Linq.</p> <p>Has anyone had to face this same issue (Linq x Subsonic)? </p> <p>What was your decision? What were the reasons?</p> <p>Any insight appreciated.</p>
[ { "answer_id": 250416, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 2, "selected": false, "text": "FROM a in db.Orders\nwhere a.Total > 100\nSELECT new {a.Item.Desc, a.Customer.Name};\n select i.DESC, c.NAME \nfrom ORDERS o \ninner join ITEMS on o.ItemID = i.ItemID \ninner join CUSTOMERS c on o.CustomerID = c.CUSTOMERID \nwhere o.TOTAL > 100\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3440/" ]
250,374
<p>With the Ajax Control Toolkit, one can easily drag and drop all types of great extender onto controls, but they register a boatload of JavaScript to do it. </p> <ol> <li>How do I control this? </li> <li>If the <code>ScriptManager</code> is in the <code>MasterPage</code>, is there anyway to control the loading of a script on one page that isn't in another?</li> </ol> <p>For example: calendar extender is on one page, but the script for it gets loaded on every page that is a child of the master page.</p>
[ { "answer_id": 250416, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 2, "selected": false, "text": "FROM a in db.Orders\nwhere a.Total > 100\nSELECT new {a.Item.Desc, a.Customer.Name};\n select i.DESC, c.NAME \nfrom ORDERS o \ninner join ITEMS on o.ItemID = i.ItemID \ninner join CUSTOMERS c on o.CustomerID = c.CUSTOMERID \nwhere o.TOTAL > 100\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
250,375
<p>for some reason, templatetags do not render in templates for django admin.</p> <p>with this snippet from: <a href="http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#shortcut-for-simple-tags" rel="nofollow noreferrer">http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#shortcut-for-simple-tags</a></p> <pre><code>{% if is_logged_in %}Thanks for logging in!{% else %}Please log in.{% endif %} </code></pre> <p>when placed in admin index.html, if a user is logged in, it shows "Please log in"</p> <p>same with templatetags, can not get any app ones to show, do anything. there is no error/they do not get processed either </p>
[ { "answer_id": 250479, "author": "Brett", "author_id": 11958, "author_profile": "https://Stackoverflow.com/users/11958", "pm_score": 3, "selected": false, "text": "is_logged_in Please log in. if else if {% if not request.user.is_anonymous %} ..." } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
250,377
<p>As they are in .Net 3.5. I know they are in 4.0, as that's what the DLR works with, but I'm interested in the version we have now.</p>
[ { "answer_id": 250896, "author": "Tim Robinson", "author_id": 32133, "author_profile": "https://Stackoverflow.com/users/32133", "pm_score": 2, "selected": false, "text": "while for Enumerable" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18658/" ]
250,378
<p>Can source code examples be kept in a SQL database <strong>while retaining all formatting</strong> (tabs, newlines, etc.)? If so what data type would be used?</p>
[ { "answer_id": 250384, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": true, "text": "TEXT MEDIUMTEXT LONGTEXT" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
250,398
<p>I can't find any proper documentation on how to specify relations using the declarative syntax of SQLAlchemy.. Is it unsupported? That is, should I use the "traditional" syntax?<br> I am looking for a way to specify relations at a higher level, avoiding having to mess with foreign keys etc.. I'd like to just declare "addresses = OneToMany(Address)" and let the framework handle the details.. I know that Elixir can do that, but I was wondering if "plain" SQLA could do it too.<br> Thanks for your help!</p>
[ { "answer_id": 251077, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 3, "selected": true, "text": "class User(Base):\n __tablename__ = 'users'\n\n id = Column('id', Integer, primary_key=True)\n addresses = relation(\"Address\", backref=\"user\")\n\nclass Address(Base):\n __tablename__ = 'addresses'\n\n id = Column('id', Integer, primary_key=True)\n user_id = Column('user_id', Integer, ForeignKey('users.id'))\n" }, { "answer_id": 1094626, "author": "Gregg Lind", "author_id": 15842, "author_profile": "https://Stackoverflow.com/users/15842", "pm_score": 0, "selected": false, "text": "class Address(Base):\n __tablename__ = 'addresses'\n\n id = Column(Integer, primary_key=True)\n email = Column(String(50))\n user_id = Column(Integer, ForeignKey('users.id'))\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3497/" ]
250,403
<p>I'm auditing a project that uses what is called a <a href="http://en.wikipedia.org/wiki/Business_rules_engine" rel="noreferrer">Rules Engine</a>. In short, it's a way to externalize business logic from application code. </p> <p>This concept is entirely new to me and I'm pretty skeptical about it. After hearing people talk about <a href="http://www.martinfowler.com/bliki/AnemicDomainModel.html" rel="noreferrer">Anemic Domain Models</a> for the past few years, I'm questioning the Rules Engine Approach. To me they seem like a great way to WEAKEN a domain model. For example say I'm doing a java webapp interacting with a Rules Engine. Then I decide I want to have an Android app based on the same domain. Unless I want the Android app to interact with the Rules Engine as well, I'm going to have to miss out on whatever business logic was already written. </p> <p>As I don't have any experience with them yet, just curiosity, I was interested to hear about the pros and cons are in using a Rules Engine? The only pro that I can think of is that you don't need to rebuild your entire Application just to change some business rule (but really, how many apps really have that many changes?). But using a Rules Engine to solve that problem kind of sounds to me like putting a band-aid over a shotgun wound. </p> <p>UPDATE - since writing this, the god himself, Martin Fowler, has <a href="http://martinfowler.com/bliki/RulesEngine.html" rel="noreferrer">blogged about using a Rules engine</a>.</p>
[ { "answer_id": 250641, "author": "brian d foy", "author_id": 2766176, "author_profile": "https://Stackoverflow.com/users/2766176", "pm_score": 4, "selected": false, "text": "if" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
250,404
<p>I found <a href="https://stackoverflow.com/questions/122778/capture-console-output-for-debugging-in-vs">this question</a>, but what I want to know is different - does the output from Console.WriteLine go anywhere when debugging? I know that for it to go to the output window I should should Debug.WriteLine() or other methods, but where does the standard Console.WriteLine() go?</p> <p><strong>Edit</strong> When debugging, you don't see the black console window / test log - so the <strong>real question is</strong> how can I access/view this output during debugging?</p>
[ { "answer_id": 2075892, "author": "AMissico", "author_id": 163921, "author_profile": "https://Stackoverflow.com/users/163921", "pm_score": 3, "selected": false, "text": "NullStream Stream Console GetStdHandle NullStream Console.SetOut(New System.IO.StreamWriter(\"C:\\ConsoleOutput.txt\")) ConsoleTraceListener StreamWriter Dim oLogFile As New System.IO.StreamWriter(\"C:\\ConsoleOutput.txt\")\n oLogFile.AutoFlush = True 'so we do not have to worry about flushing before application exit\n\n Console.SetOut(oLogFile)\n\n 'note, writing to debug and trace causes output on console, so you will get double output in log file\n Dim oListener As New ConsoleTraceListener\n Debug.Listeners.Add(oListener)\n Trace.Listeners.Add(oListener)\n [Serializable]\nprivate sealed class NullStream : Stream {\n internal NullStream() { }\n\n public override bool CanRead {\n get { return true; }\n }\n\n public override bool CanWrite {\n get { return true; }\n }\n\n public override bool CanSeek {\n get { return true; }\n }\n\n public override long Length {\n get { return 0; }\n }\n\n public override long Position {\n get { return 0; }\n set { }\n }\n\n // No need to override Close\n\n public override void Flush() {\n }\n\n public override int Read([In, Out] byte[] buffer, int offset, int count) {\n return 0;\n }\n\n public override int ReadByte() {\n return -1;\n }\n\n public override void Write(byte[] buffer, int offset, int count) {\n }\n\n public override void WriteByte(byte value) {\n }\n\n public override long Seek(long offset, SeekOrigin origin) {\n return 0;\n }\n\n public override void SetLength(long length) {\n }\n} \n" }, { "answer_id": 5577749, "author": "Carl R", "author_id": 480986, "author_profile": "https://Stackoverflow.com/users/480986", "pm_score": 4, "selected": false, "text": "using System.Diagnostics;\nusing System.IO;\nusing System.Text;\n\nnamespace TestConsole\n{\n public class DebugTextWriter : TextWriter\n {\n public override Encoding Encoding\n {\n get { return Encoding.UTF8; }\n }\n\n //Required\n public override void Write(char value)\n {\n Debug.Write(value);\n }\n\n //Added for efficiency\n public override void Write(string value)\n {\n Debug.Write(value);\n }\n\n //Added for efficiency\n public override void WriteLine(string value)\n {\n Debug.WriteLine(value);\n }\n }\n}\n using System;\n\nnamespace TestConsole\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.SetOut(new DebugTextWriter());\n Console.WriteLine(\"This text goes to the Visual Studio output window.\");\n }\n }\n}\n using System.IO;\nusing System.Runtime.InteropServices;\nusing System.Text;\n\nnamespace TestConsole\n{\n public class OutputDebugStringTextWriter : TextWriter\n {\n [DllImport(\"kernel32.dll\")]\n static extern void OutputDebugString(string lpOutputString);\n\n public override Encoding Encoding\n {\n get { return Encoding.UTF8; }\n }\n\n //Required\n public override void Write(char value)\n {\n OutputDebugString(value.ToString());\n }\n\n //Added for efficiency\n public override void Write(string value)\n {\n OutputDebugString(value);\n }\n\n //Added for efficiency\n public override void WriteLine(string value)\n {\n OutputDebugString(value);\n }\n }\n}\n" }, { "answer_id": 47306894, "author": "Remus Rusanu", "author_id": 105929, "author_profile": "https://Stackoverflow.com/users/105929", "pm_score": 1, "selected": false, "text": "/target:winexe Console.Write /target:exe Console.Write stdout" }, { "answer_id": 50456898, "author": "Corey Byrum", "author_id": 7723049, "author_profile": "https://Stackoverflow.com/users/7723049", "pm_score": 3, "selected": false, "text": " catch (DbEntityValidationException dbEx)\n {\n foreach (var validationErrors in dbEx.EntityValidationErrors)\n {\n foreach (var validationError in validationErrors.ValidationErrors)\n {\n System.Diagnostics.Debug.WriteLine(\"Property: {0} Error: {1}\", validationError.PropertyName, validationError.ErrorMessage);\n }\n }\n" }, { "answer_id": 60656340, "author": "s3c", "author_id": 9583480, "author_profile": "https://Stackoverflow.com/users/9583480", "pm_score": 0, "selected": false, "text": "Console.WriteLine(\"Debug MyVariable: \" + MyVariable)" }, { "answer_id": 73628954, "author": "Justin Edwards", "author_id": 13360064, "author_profile": "https://Stackoverflow.com/users/13360064", "pm_score": 1, "selected": false, "text": "using System.Diagnostics; Debug.WriteLine(\"Hello World\");" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
250,408
<p>I tried the example from Rails Cookbook and managed to get it to work. However the <code>text_field_with_auto_complete</code> works only for one value.</p> <pre><code>class Expense &lt; ActiveRecord::Base has_and_belongs_to_many :categories end </code></pre> <p>In the New Expense View rhtml</p> <pre><code>&lt;%= text_field_with_auto_complete :category, :name %&gt; </code></pre> <p>Auto complete works for the first category. How do I get it working for multiple categories? e.g. Category1, Category2<br> <em>Intended behavior: like the StackOverflow Tags textbox</em></p> <p><strong>Update:</strong><br> With some help and some more tinkering, I got multiple comma-seperated autocomplete to show up (will post code-sample here).<br> <em>However on selection, the last value replaces the content of the text_field_with_auto_complete.</em> So instead of Category1, Category2.. the textbox shows Category2 when the second Category is selected via auto-complete. Any ideas how to rectify this? </p>
[ { "answer_id": 9945411, "author": "Rustam A. Gasanov", "author_id": 644810, "author_profile": "https://Stackoverflow.com/users/644810", "pm_score": 0, "selected": false, "text": "<%= f.autocomplete_field :brand_name, welcome_autocomplete_brand_name_path, \"data-delimiter\" => ', ' %>" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
250,410
<p>If I write <code>Session["asdf"] = 234;</code></p> <p>In my asp.net web app, does this mean the client will have a cookie stored on their browser?</p>
[ { "answer_id": 250414, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 4, "selected": false, "text": "lit3py55t21z5v55vlm25s55" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
250,415
<p>I need to write some registration data (unique computer number, and corresponding activation code).</p> <p>The Computer Number needs to be visible from <i>other</i> programs and <em>all</em> accounts ({Admin|Non Admin} with User Access Control turned {On|Off} )</p> <p>It's acceptable to write the Computer Number and Activation Code only from an Admin account, but it needs to be readable from any of the other accounts. </p> <p>Currently (and I need to test this more) it seems that if the the CN and Activation Code are written with UAC off then when the user switches UAC ON the Computer Number isn't visible.</p>
[ { "answer_id": 250414, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 4, "selected": false, "text": "lit3py55t21z5v55vlm25s55" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4906/" ]
250,421
<p>I am writing a macro for Visual studio that will generate some code.</p> <p>I would like for the macro to generate for both C# and VB, is there a way to determine what language is being used in the active (current) document?</p>
[ { "answer_id": 250532, "author": "Brian Schmitt", "author_id": 30492, "author_profile": "https://Stackoverflow.com/users/30492", "pm_score": 3, "selected": true, "text": "DTE.ActiveDocument.Language = \"CSharp\"\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30492/" ]
250,423
<p>I'm a web developer with no formal computing background behind me, I've been writing code now some years now, but every time I need to create a new class / function / variable, I spend about two minutes just deciding on a name and then how to type it.</p> <p>For instance, if I write a function to sum up a bunch of numbers. Should I call it</p> <pre><code>Sum() GetSum() getSum() get_sum() AddNumbersReturnTotal() </code></pre> <p>I know there is a right way to do this, and a link to a good definitive source is all I ask :D</p> <p><strong>Closed as a duplicate of <a href="https://stackoverflow.com/questions/14967/c-coding-standard-best-practices">c# Coding standard / Best practices</a></strong></p>
[ { "answer_id": 250440, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 0, "selected": false, "text": "Sum() GetSum() XXX GetXXX" }, { "answer_id": 250442, "author": "Nicholas Mancuso", "author_id": 8945, "author_profile": "https://Stackoverflow.com/users/8945", "pm_score": 3, "selected": true, "text": "public class MyClass\n public void MyMethod()\nprivate void myPrivateMethod()\n private int _count;\n int count;\n" }, { "answer_id": 250480, "author": "Tim Robinson", "author_id": 32133, "author_profile": "https://Stackoverflow.com/users/32133", "pm_score": 0, "selected": false, "text": "Sum AddNumbersReturnTotal" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31765/" ]
250,451
<p>It's rare that I hear someone using <a href="http://martinfowler.com/articles/injection.html" rel="nofollow noreferrer">Inversion of Control (Ioc)</a> principle with .Net. I have some friends that work with Java that use a lot more Ioc with Spring and PicoContainer.</p> <p>I understand the principle of removing dependencies from your code... but I have a doubt that it's so much better.</p> <p><strong>Why do .Net programmers not use (or use less) those types of frameworks? If you do, do you really find a positive effect in the long term?</strong></p>
[ { "answer_id": 250483, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 2, "selected": false, "text": "IPersonMapper" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
250,468
<p>Is the SqlClient.SqlDataReader a .NET managed object or not? Why do we have to call the Close() method explicitly close an open connection? Shouldn't running out of scope for such an object automatically close this? Shouldn't garbage collector clean it up anyway?</p> <p>Please help me understand what is the best practise here.</p> <p>I have seen a related question <a href="https://stackoverflow.com/questions/247311/sqldatareader-in-this-scenario-will-the-reader-get-closed">here</a> and it further illustrates the issue I have with a web application. The issue is that we were running out of connections. The detailed error is here:</p> <pre><code>Exception: System.InvalidOperationException Message: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Source: System.Data at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean&amp; isInTransaction) at System.Data.SqlClient.SqlConnection.Open() </code></pre> <p>To fix this, I had to explicitly close all the SQLDataReader objects.</p> <p>I am using .NET Framework 3.5</p>
[ { "answer_id": 250535, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 4, "selected": false, "text": "using (SqlConnection conn = new SqlConnection(conStr))\n{\n using (SqlCommand command = new SqlCommand())\n {\n // ETC\n } \n}\n" }, { "answer_id": 250557, "author": "Jeffrey Harrington", "author_id": 4307, "author_profile": "https://Stackoverflow.com/users/4307", "pm_score": 4, "selected": false, "text": "SqlDataReader rdr = cmd.ExecuteReader( CommandBehavior.CloseConnection );\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
250,494
<p>I have a class that downloads, examines and saves some large XML files. Sometimes I want the UI to tell me what's going on, but sometimes I will use the class and ignore the events. So I have placed lines of code like this in a dozen places:</p> <pre><code>RaiseEvent Report("Sending request: " &amp; queryString) RaiseEvent Report("Saving file: " &amp; fileName) RaiseEvent Report("Finished") </code></pre> <p>My question is this - will these events slow down my code if nothing is listening for them? Will they even fire?</p>
[ { "answer_id": 250830, "author": "Binary Worrier", "author_id": 18797, "author_profile": "https://Stackoverflow.com/users/18797", "pm_score": 4, "selected": true, "text": "GetMystring() if (MyEvent != null)\n MyEvent(GetMyString())\n" }, { "answer_id": 250897, "author": "Shane Miskin", "author_id": 16415, "author_profile": "https://Stackoverflow.com/users/16415", "pm_score": 3, "selected": false, "text": "RaiseEvent Report(GetMyString())\n GetMystring" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16415/" ]
250,506
<p>I made a class that derives from Component:</p> <pre><code>public class MyComponent: System.ComponentModel.Component { } </code></pre> <p>I saw that Visual Studio put this code in for me:</p> <pre><code>protected override void Dispose(bool disposing) { try { if (disposing &amp;&amp; (components != null)) { components.Dispose(); } } catch { throw; } finally { base.Dispose(disposing); } } </code></pre> <p><code>MyComponent</code> has a member that is a <code>DataSet</code> and maybe there's some other members that implement <code>IDisposable</code>. What, if anything, do i need to modify with the <code>Dispose()</code> method to make sure things are cleaned up properly? Thanks for helping.</p>
[ { "answer_id": 250541, "author": "Nicholas Mancuso", "author_id": 8945, "author_profile": "https://Stackoverflow.com/users/8945", "pm_score": 3, "selected": true, "text": "if (disposing && (components != null))\n{\n components.Dispose();\n}\n if (disposing && (components != null))\n{\n _dataset.Dispose();\n components.Dispose();\n}\n" }, { "answer_id": 9169564, "author": "smoothdeveloper", "author_id": 17049, "author_profile": "https://Stackoverflow.com/users/17049", "pm_score": 0, "selected": false, "text": "public class DisposableComponentWrapper : IComponent\n{\n private IDisposable disposable;\n\n public DisposableComponentWrapper(IDisposable disposable)\n {\n this.disposable = disposable;\n }\n\n public DisposableComponentWrapper(IDisposable disposable, ISite site)\n : this(disposable)\n {\n Site = site;\n }\n\n public void Dispose()\n {\n if (disposable != null)\n {\n disposable.Dispose();\n }\n if (Disposed != null)\n {\n Disposed(this, EventArgs.Empty);\n }\n }\n\n public ISite Site { get; set; }\n\n public event EventHandler Disposed;\n}\n public static void Add(this IContainer container, IDisposable disposableComponent)\n{\n var component = (disposableComponent as IComponent);\n if(component == null)\n {\n component = new DisposableComponentWrapper(disposableComponent);\n }\n container.Add(component);\n}\n" }, { "answer_id": 59382238, "author": "Palec", "author_id": 2157640, "author_profile": "https://Stackoverflow.com/users/2157640", "pm_score": -1, "selected": false, "text": "components public partial class MyComponent : System.ComponentModel.Component\n{\n private readonly System.Data.DataSet _dataSet;\n\n public MyComponent(System.Data.DataSet dataSet)\n {\n _dataSet = dataSet ?? throw new System.ArgumentNullException(nameof(dataSet));\n components.Add(new DisposableWrapperComponent(dataSet));\n }\n}\n DisposableWrapperComponent using System;\nusing System.ComponentModel;\n\npublic class DisposableWrapperComponent : Component\n{\n private bool disposed;\n\n public IDisposable Disposable { get; }\n\n public DisposableWrapperComponent(IDisposable disposable)\n {\n Disposable = disposable ?? throw new ArgumentNullException(nameof(disposable));\n }\n\n protected override void Dispose(bool disposing)\n {\n if (disposed) return;\n\n if (disposing)\n {\n Disposable.Dispose();\n }\n\n base.Dispose(disposing);\n\n disposed = true;\n }\n}\n using System;\nusing System.ComponentModel;\nusing System.Data;\n\npublic partial class MyComponent : Component\n{\n private const string DataSetComponentName = \"dataSet\";\n\n public DataSet DataSet\n {\n get => (DataSet)((DisposableWrapperComponent)components.Components[DataSetComponentName])\n ?.Disposable;\n set\n {\n var lastWrapper = (DisposableWrapperComponent)components.Components[DataSetComponentName];\n if (lastWrapper != null)\n {\n components.Remove(lastWrapper);\n lastWrapper.Dispose();\n }\n\n if (value != null)\n {\n components.Add(new DisposableWrapperComponent(value), DataSetComponentName);\n }\n }\n }\n\n public MyComponent(DataSet dataSet)\n {\n DataSet = dataSet ?? throw new ArgumentNullException(nameof(dataSet));\n }\n}\n OnStart OnStop" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
250,508
<p>I am trying to pull data from an ACD call data system, <code>Nortel Contact Center 6.0</code> to be exact, and if you use that particular system what I am trying to capture is the daily call by call data. However when I use this code</p> <p>(sCW is a common word string that equals <code>eCallByCallStat</code> and sDate is </p> <p><code>dDate = Format(Month(deffDate) &amp; "/" &amp; iStartDay &amp; "/" &amp; Year(deffDate), "mm/dd/yyyy")</code></p> <p><code>sDate = Format(dDate, "yyyymmdd")</code> )</p> <pre><code>sSql = "" sConn = "ODBC;DSN=Aus1S002;UID=somevaliduser;PWD=avalidpassword;SRVR=Thecorrectserver;DB=blue" sSql = "SELECT " &amp; sCW &amp; sDate &amp; ".Timestamp, " sSql = sSql &amp; sCW &amp; sDate &amp; ".CallEvent, " sSql = sSql &amp; sCW &amp; sDate &amp; ".CallEventName, " sSql = sSql &amp; sCW &amp; sDate &amp; ".CallID, " sSql = sSql &amp; sCW &amp; sDate &amp; ".TelsetLoginID, " sSql = sSql &amp; sCW &amp; sDate &amp; ".AssociatedData, " sSql = sSql &amp; sCW &amp; sDate &amp; ".Destination, " sSql = sSql &amp; sCW &amp; sDate &amp; ".EventData, " sSql = sSql &amp; sCW &amp; sDate &amp; ".Source, " sSql = sSql &amp; sCW &amp; sDate &amp; ".Time " &amp; vbCrLf sSql = sSql &amp; "FROM blue.dbo.eCallByCallStat" &amp; sDate &amp; " " &amp; sCW &amp; sDate &amp; vbCrLf sSql = sSql &amp; " ORDER BY " &amp; sCW &amp; sDate &amp; ".Timestamp" Set oQT = ActiveSheet.QueryTables.Add(Connection:=sConn, Destination:=Range("A1"), Sql:=sSql) oQT.Refresh BackgroundQuery:=False Do While oQT.Refreshing = True Loop" </code></pre> <p>When I run this I get an odd error message at oQT.Refresh BackgroundQuery:=False</p> <p>Oddly enough it worked for a month or so then just died</p> <hr> <p>@ loopo I actually added the <code>""</code> to the connection string and actually have the user name and password hard coded into the query with out quotes, I have since removed them for clarity in the posting</p> <hr> <p>The error I recieve is </p> <blockquote> <p>Run-time error '-2147417848(80010108)': Method 'Refresh" of Object "_QueryTable' Failed</p> </blockquote> <hr> <p>Thanks for your input Kevin. The Database is never in a state where no one is accessing it, it is a Call Handling system that is on 24 x 7 and always connected to is clients. At least that is my understanding. If I do this manually through Excel I never get an error, or have any issues only when I am doing this via a macro does it give me issues which lead me to think that it was my code causing the issue.</p> <p>I am connecting to the database via ODBC as recommended by the manuafacturer, but I wonder if they ever envisioned this sort of thing.</p> <p>I will see if I can leverage this into a .NET project and see if that helps.</p>
[ { "answer_id": 250929, "author": "Loopo", "author_id": 32763, "author_profile": "https://Stackoverflow.com/users/32763", "pm_score": 1, "selected": false, "text": "sConn = \"ODBC;DSN=Aus1S002;UID=\"\"somevaliduser\"\";PWD=\"\"avalidpassword\"\";SRVR=\"\"Thecorrectserver\"\";DB=blue\"\n" }, { "answer_id": 250930, "author": "CABecker", "author_id": 32790, "author_profile": "https://Stackoverflow.com/users/32790", "pm_score": 0, "selected": false, "text": "sSql=\"\" sSQL=SELECT eCallByCallStat20081001.Timestamp, eCallByCallStat20081001.CallEvent,\neCallByCallStat20081001.CallEventName, eCallByCallStat20081001.CallID,\neCallByCallStat20081001.TelsetLoginID, eCallByCallStat20081001.AssociatedData,\neCallByCallStat20081001.Destination, eCallByCallStat20081001.EventData,\neCallByCallStat20081001.Source, eCallByCallStat20081001.Time FROM \nblue.dbo.eCallByCallStat20081001 eCallByCallStat20081001 ORDER BY\neCallByCallStat20081001.Timestamp\n" }, { "answer_id": 252479, "author": "Loopo", "author_id": 32763, "author_profile": "https://Stackoverflow.com/users/32763", "pm_score": 1, "selected": false, "text": "SELECT Timestamp, CallEvent, ... ,Time \n FROM blue.dbo.eCallByCallStat\" & sDate & \" ORDER BY Timestamp \n" }, { "answer_id": 62076016, "author": "szabo357", "author_id": 8297311, "author_profile": "https://Stackoverflow.com/users/8297311", "pm_score": 0, "selected": false, "text": "Ws.ListObjects(\"TableName\").QueryTable.Refresh BackgroundQuery:=False ThisWorkbook.Connections(\"ConnectionName\").Refresh" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32790/" ]
250,509
<p>Is there a way that you can have SERVEROUTPUT set to ON in sqlplus but somehow repress the message "PL/SQL procedure successfully completed" that is automatically generated upon completed execution of a plsql procedure?</p>
[ { "answer_id": 250540, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 7, "selected": true, "text": "SET FEEDBACK OFF\n SET FEEDBACK ON\n" }, { "answer_id": 58718276, "author": "MikeA", "author_id": 10807594, "author_profile": "https://Stackoverflow.com/users/10807594", "pm_score": 1, "selected": false, "text": "create or replace procedure test_throw_an_error as buzz number; begin dbms_output.put_line('In test_throw_an_error. Now, to infinity!'); buzz:=1/0; end;\n/\nset serveroutput on\nset feedback off\nexec test_throw_an_error;\nexec dbms_output.put_line('Done, with feedback off');\nset feedback on\nexec test_throw_an_error;\nexec dbms_output.put_line('Done, with feedback on');\n Procedure TEST_THROW_AN_ERROR compiled\n\nIn test_throw_an_error. Now, to infinity!\n\nDone, with feedback off\n\nIn test_throw_an_error. Now, to infinity!\n\n\nError starting at line : 11 in command -\nBEGIN test_throw_an_error; END;\nError report -\nORA-01476: divisor is equal to zero\nORA-06512: at \"ECTRUNK.TEST_THROW_AN_ERROR\", line 1\nORA-06512: at line 1\n01476. 00000 - \"divisor is equal to zero\"\n*Cause: \n*Action:\nDone, with feedback on\n\nPL/SQL procedure successfully completed.\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5658/" ]
250,517
<p>I see many different Java terms floating around. I need to install the JDK 1.6. It was my understanding that Java 6 == Java 1.6. However, when I install Java SE 6, I get a JVM that reports as version 11.0! Who can solve the madness?</p>
[ { "answer_id": 250534, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 8, "selected": false, "text": "sun.com" }, { "answer_id": 250559, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 7, "selected": true, "text": "1.6.0_07 1.6.0_07-b06 build 10.0-b23, mixed mode\"" }, { "answer_id": 23456523, "author": "Manav", "author_id": 141220, "author_profile": "https://Stackoverflow.com/users/141220", "pm_score": 5, "selected": false, "text": "javac -version java -version" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1541/" ]
250,545
<p>Does anyone know of any specific DSL implementations used to import legacy Oracle database schemas. I have tried to just run db:schema:dump on my existing db I want to port to a new ruby app. However, the rake dies about halfway through with out any error. It kinda just locks up. I started looking for the best way to tackle this and found examples of how to override some stuff for SQLServer but not much for Oracle. </p> <p>I basically want to pull in the schema and generate a scaffold and model from it.</p> <p>Is there a more simple way to do this or will I have to invent the wheel?</p>
[ { "answer_id": 250725, "author": "Gene T", "author_id": 413049, "author_profile": "https://Stackoverflow.com/users/413049", "pm_score": 3, "selected": true, "text": "rake --trace" }, { "answer_id": 252864, "author": "Raimonds Simanovskis", "author_id": 16829, "author_profile": "https://Stackoverflow.com/users/16829", "pm_score": 3, "selected": false, "text": "rake db:schema:dump\n rake db:structure:dump\n" }, { "answer_id": 5003968, "author": "Diego Plentz", "author_id": 406174, "author_profile": "https://Stackoverflow.com/users/406174", "pm_score": 1, "selected": false, "text": "~/Projects/test (master) $ rake db:structure:dump\n(in /Users/plentz/Projects/test)\nrake aborted!\nTask not supported by 'oracle_enhanced'\n\n(See full trace by running task with --trace)\n gem 'activerecord-oracle_enhanced-adapter', :require => false\n Using activerecord-oracle_enhanced-adapter (1.3.2) \n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30807/" ]
250,550
<p>this is probably a newbie ruby question. I have several libraries and apps that I need to deploy to several different hosts. All of the apps and libs will share some common settings for those hosts-- e.g. host name, database server/user/pass, etc.</p> <p>My goal is to do something like:</p> <pre><code>cap host1 stage deploy cap host2 stage deploy cap host1 prod deploy # ... </code></pre> <p>My question is how do you include these common settings in all of your deploy.rb files? More specifically, I want to create a an rb file that I can include that has some common settings and several host specific task definitions:</p> <pre><code>set :use_sudo, false # set some other options task :host1 do role :app, "host1.example.com" role :web, "host1.example.com" role :db, "host1.example.com", :primary =&gt; true set :rodb_host, "dbhost" set :rodb_user, "user" set :rodb_pass, "pass" set :rodb_name, "db" end task :host2 do #... end deploy.task :carsala do transaction do setup update_code symlink end end </code></pre> <p>And then "include" this file in all of my deploy.rb files where I define stage, prod, etc and overwrite any "common" configuration parameters as necessary. Any suggestions would be appreciated. I've tried a few different things, but I get errors from cap for all of them. </p> <p>Edit: I've tried </p> <pre><code>require 'my_module' </code></pre> <p>But I get errors complaining about an undefined task object.</p>
[ { "answer_id": 250747, "author": "Jon Wood", "author_id": 25258, "author_profile": "https://Stackoverflow.com/users/25258", "pm_score": 2, "selected": false, "text": "require 'my_extension'\n" }, { "answer_id": 250985, "author": "Daniel Beardsley", "author_id": 13216, "author_profile": "https://Stackoverflow.com/users/13216", "pm_score": 0, "selected": false, "text": "require 'filename'" }, { "answer_id": 251862, "author": "Damon Snyder", "author_id": 8243, "author_profile": "https://Stackoverflow.com/users/8243", "pm_score": 3, "selected": false, "text": "load 'config/my_module'\n" }, { "answer_id": 254327, "author": "Ian Terrell", "author_id": 9269, "author_profile": "https://Stackoverflow.com/users/9269", "pm_score": 0, "selected": false, "text": "set :application, \"app\"\n\nset :scm, :subversion\n# ... set all your common variables\n\ntask :staging do\n set :repository, \"http://app/repository/trunk/\"\n # ... set other uncommon variables in task\nend\n\ntask :production do\n set :repository, \"http://app/repository/production/\"\n # ...\nend\n cap staging deploy\n cap production deploy\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8243/" ]
250,553
<p>I'd like something like</p> <pre><code>int minIndex = list.FindMin(delegate (MyClass a, MyClass b) {returns a.CompareTo(b);}); </code></pre> <p>Is there a builtin way to do this in .NET?</p>
[ { "answer_id": 250567, "author": "Nicholas Mancuso", "author_id": 8945, "author_profile": "https://Stackoverflow.com/users/8945", "pm_score": 6, "selected": true, "text": "List<MyClass> list = new List();\n//add whatever you need to add\n\nMyClass min = list.Min();\nMyClass max = list.Max();\n" }, { "answer_id": 250568, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 2, "selected": false, "text": "list.AsQueryable().Min();" }, { "answer_id": 251800, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "MyClass min = Enumerable.Min(list),\n max = Enumerable.Max(list);\n static void Main()\n{\n int[] data = { 3, 5, 1, 5, 5 };\n int min = Min(data);\n}\nstatic T Min<T>(IEnumerable<T> values)\n{\n return Min<T>(values, Comparer<T>.Default);\n}\nstatic T Min<T>(IEnumerable<T> values, IComparer<T> comparer)\n{\n bool first = true;\n T result = default(T);\n foreach(T value in values) {\n if(first)\n {\n result = value;\n first = false;\n }\n else\n {\n if(comparer.Compare(result, value) > 0) \n {\n result = value;\n }\n }\n }\n return result;\n}\n" }, { "answer_id": 251841, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 4, "selected": false, "text": "List<SomeClass> list = new List<SomeClass>();\n// populate the list\n// assume that SomeClass implements IComparable\nlist.Sort();\nreturn list[0]; // min, or\nreturn list[list.Count - 1]; // max\n list.Sort(delegate(SomeClass x, SomeClass y) { return string.Compare(x.Name, y.Name); });\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
250,560
<p>I am working in Java on a fairly large project. My question is about how to best structure the set of Properties for my application.</p> <p>Approach 1: Have some static Properties object that's accessible by every class. (Disadvantages: then, some classes lose their generality should they be taken out of the context of the application; they also require explicit calls to some static object that is located in a different class and may in the future disappear; it just doesn't <em>feel</em> right, am I wrong?)</p> <p>Approach 2: Have the Properties be instantiated by the main class and handed down to the other application classes. (Disadvantages: you end up passing a pointer to the Properties object to almost every class and it seems to become very redundant and cumbersome; I don't <em>like</em> it.)</p> <p>Any suggestions?</p>
[ { "answer_id": 250585, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "ConfigurationManagerClass.instance()" }, { "answer_id": 250593, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "MySingleton.getInstance() class MyConfig extends Properties {...}\n\nclass SomeClass {\n MyConfig theConfig;\n public void setConfi( MyConfig c ) {\n theConfig= c;\n }\n ...\n}\n" }, { "answer_id": 250814, "author": "Frederic Morin", "author_id": 4064, "author_profile": "https://Stackoverflow.com/users/4064", "pm_score": 0, "selected": false, "text": "MyObject mobj = new MyObject();\nmobj.setLookupDelay(appConfig.getMyObjectLookupDelay);\nmobj.setTrackerName(appConfig.getMyObjectTrackerName);\n MyObject mobj = new MyObject();\nmobj.setConfig(appConfig);\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10675/" ]
250,564
<p>How to check, from C#, are files for complex script and rtl languages (Regional and Language settings) installed?</p> <p>Edit: Or is there another way of checking whether right to left text will display correctly in my form?</p> <p>Edit for better explanation (I hope :)) I'm creating an application that will use Arabic letters (free dictionary). So, I want to check are: "Files for complex script and right-to-left languages(Including Thai)" (CheckBox in "Regional and Language Options" in Language Tab) installed (Is CheckBox checked.). If they are not installed, Arabic words will not display correctly,and I want to warn user if that is the case.</p> <p>Thanks</p>
[ { "answer_id": 261187, "author": "Afree", "author_id": 11317, "author_profile": "https://Stackoverflow.com/users/11317", "pm_score": 0, "selected": false, "text": "...\n uint32 MaxNumberOfProcesses;\n uint64 MaxProcessMemorySize;\n string MUILanguages[]; //I don't see this field, and all others I see\n string Name;\n uint32 NumberOfLicensedUsers;\n...\n string ConfigNamespace = @\"\\\\.\\root\\cimv2\";\nstring query = \"select * from Win32_OperatingSystem\";\n\nManagementObjectSearcher searcher = \n new ManagementObjectSearcher(ConfigNamespace, query);\n\nManagementObjectCollection collection = searcher.Get();\n\nforeach (ManagementObject item in collection)\n{\n //PropertyData pd = item.Properties[\"MUILanguages\"];\n\n foreach (PropertyData data in item.Properties)\n {\n\n }\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11317/" ]
250,566
<p>What is the best plugin for Rails that <strong>gzips</strong> my webpage output?</p> <p><strong>Edit:</strong> The company I am hosting with has stated they will not install <code>mod_deflate</code>.</p>
[ { "answer_id": 251012, "author": "Otto", "author_id": 9594, "author_profile": "https://Stackoverflow.com/users/9594", "pm_score": 4, "selected": false, "text": "Content-Encoding: gzip $ curl --head -H \"Accept-Encoding: gzip\" http://example.com\n" }, { "answer_id": 13877091, "author": "Sam Figueroa", "author_id": 201524, "author_profile": "https://Stackoverflow.com/users/201524", "pm_score": 2, "selected": false, "text": "use Rack::Deflater config.ru" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
250,576
<p>In Visual Studio, is there any way to make the debugger break whenever a certain file (or class) is entered? Please don't answer "just set a breakpoint at the beginning of every method" :)</p> <p>I am using C#.</p>
[ { "answer_id": 250594, "author": "JC.", "author_id": 3615, "author_profile": "https://Stackoverflow.com/users/3615", "pm_score": 2, "selected": false, "text": "System.Diagnostics.Debugger.Break();\n" }, { "answer_id": 539655, "author": "devdimi", "author_id": 54983, "author_profile": "https://Stackoverflow.com/users/54983", "pm_score": 0, "selected": false, "text": "you can use the following macro:\n\n#ifdef _DEBUG\n#define DEBUG_METHOD(x) x DebugBreak();\n#else\n#define DEBUG_METHOD(x) x\n#endif\n\n#include <windows.h>\n\nDEBUG_METHOD(int func(int arg) {)\n return 0;\n}\n" }, { "answer_id": 539708, "author": "LarryF", "author_id": 18518, "author_profile": "https://Stackoverflow.com/users/18518", "pm_score": 0, "selected": false, "text": "__asm { int 3 }\n" }, { "answer_id": 539740, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": false, "text": ".map Breakpoints.add()" }, { "answer_id": 539811, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 3, "selected": false, "text": "bm exename!CSomeClass::*\n" }, { "answer_id": 540549, "author": "abelenky", "author_id": 34824, "author_profile": "https://Stackoverflow.com/users/34824", "pm_score": 1, "selected": false, "text": "void MyFunction()\n{\n Debugger.Break();\n Console.WriteLine(\"More stuff...\");\n}\n" }, { "answer_id": 540580, "author": "Daniel Daranas", "author_id": 96780, "author_profile": "https://Stackoverflow.com/users/96780", "pm_score": 1, "selected": false, "text": "public int Whatever(int blah, bool duh)\n{\n // INVARIANT (i)\n // PRECONDITION CHECK (ii)\n\n // BODY (iii)\n\n // POSTCONDITION CHECK (iv)\n // INVARIANT (v)\n\n}\n" }, { "answer_id": 540586, "author": "thinkbeforecoding", "author_id": 47001, "author_profile": "https://Stackoverflow.com/users/47001", "pm_score": 0, "selected": false, "text": "Debugger.Launch() Debugger.Break() System.Diagnostics" }, { "answer_id": 540598, "author": "Richard Szalay", "author_id": 3603, "author_profile": "https://Stackoverflow.com/users/3603", "pm_score": 7, "selected": true, "text": "Public Module ClassBreak\n Public Sub BreakOnAnyMember()\n Dim debugger As EnvDTE.Debugger = DTE.Debugger\n Dim sel As EnvDTE.TextSelection = DTE.ActiveDocument.Selection\n Dim editPoint As EnvDTE.EditPoint = sel.ActivePoint.CreateEditPoint()\n Dim classElem As EnvDTE.CodeElement = editPoint.CodeElement(vsCMElement.vsCMElementClass)\n\n If Not classElem Is Nothing Then\n For Each member As EnvDTE.CodeElement In classElem.Children\n If member.Kind = vsCMElement.vsCMElementFunction Then\n debugger.Breakpoints.Add(member.FullName)\n End If\n Next\n End If\n End Sub\n\nEnd Module\n" }, { "answer_id": 543816, "author": "M4N", "author_id": 19635, "author_profile": "https://Stackoverflow.com/users/19635", "pm_score": 3, "selected": false, "text": "[Serializable]\npublic sealed class DebugBreakAttribute : PostSharp.Laos.OnMethodBoundaryAspect\n{\n public DebugBreakAttribute() {}\n public DebugBreakAttribute(string category) {}\n public string Category { get { return \"DebugBreak\"; } }\n\n public override void OnEntry(PostSharp.Laos.MethodExecutionEventArgs eventArgs)\n {\n base.OnEntry(eventArgs);\n // debugger will break here. Press F10 to continue to the \"real\" method\n System.Diagnostics.Debugger.Break();\n }\n}\n [DebugBreak(\"DebugBreak\")]\npublic class MyClass\n{\n public MyClass()\n {\n // ...\n }\n public void Test()\n {\n // ...\n }\n}\n" }, { "answer_id": 556958, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 0, "selected": false, "text": "MethodRental.SwapMethodBody void SetBreakpointsForAllMethodsAndConstructorsInClass (string classname)\n{\n find type information for class classname\n for each constructor and method\n get MSIL bytes\n prepend call to System.Diagnostics.Debugger.Break to MSIL bytes\n fix up MSIL code (I'm not familiar with the MSIL spec. Generally, absolute jump targets need fixing up)\n call SwapMethodBody with new MSIL\n}\n" }, { "answer_id": 3666880, "author": "Gustaf Carleson", "author_id": 270307, "author_profile": "https://Stackoverflow.com/users/270307", "pm_score": 1, "selected": false, "text": "Public Sub RemoveBreakOnAnyMember()\n Dim debugger As EnvDTE.Debugger = DTE.Debugger\n\n Dim bps As Breakpoints\n bps = debugger.Breakpoints\n\n If (bps.Count > 0) Then\n Dim bp As Breakpoint\n For Each bp In bps\n Dim split As String() = bp.File.Split(New [Char]() {\"\\\"c})\n\n If (split.Length > 0) Then\n Dim strName = split(split.Length - 1)\n If (strName.Equals(DTE.ActiveDocument.Name)) Then\n bp.Delete()\n End If\n End If\n Next\n End If\nEnd Sub\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
250,577
<p>I have an Ant script with a junit target where I want it to start up the VM with a different working directory than the basedir. How would I do this?</p> <p>Here's a pseudo version of my target.</p> <pre><code>&lt;target name="buildWithClassFiles"&gt; &lt;mkdir dir="${basedir}/UnitTest/junit-reports"/&gt; &lt;junit fork="true" printsummary="yes"&gt; &lt;classpath&gt; &lt;pathelement location="${basedir}/UnitTest/bin"/&gt; &lt;path refid="classpath.compile.tests.nojars"/&gt; &lt;/classpath&gt; &lt;jvmarg value="-javaagent:${lib}/jmockit/jmockit.jar=coverage=:html"/&gt; &lt;formatter type="xml" /&gt; &lt;test name="GlobalTests" todir="${basedir}/UnitTest/junit-reports" /&gt; &lt;/junit&gt; &lt;/target&gt; </code></pre>
[ { "answer_id": 250651, "author": "James Van Huis", "author_id": 31828, "author_profile": "https://Stackoverflow.com/users/31828", "pm_score": 3, "selected": false, "text": " <junit fork=\"true\" printsummary=\"yes\" dir=\"workingdir\">\n" }, { "answer_id": 250927, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 0, "selected": false, "text": "user.dir <junit fork=\"true\" ...>\n <jvmarg value=\"-Duser.dir=${desired.current.dir}\"/>\n ....\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
250,582
<p>Which language for quick GUI app + sqlite database CRUD (2-4 tables). Java, Python? (Please no jokes like VBasic), some reference, source code to look on?</p> <p>added:</p> <p>First idea: 1 database SQLite (Win) + client GUI app (Win) clients table + orders table + others import, export database add, del, edit, etc. entries</p> <p>Second idea: 1 hosted database (PostgreSQL ,MySQL) + web app client clients table + orders table + others import, export database add, del, edit, etc. entries</p> <p>Thinking about Django, RoR or local Java(Netbeans), Python(wxPython+ORM).</p> <p>???</p>
[ { "answer_id": 250967, "author": "robintw", "author_id": 1912, "author_profile": "https://Stackoverflow.com/users/1912", "pm_score": 3, "selected": true, "text": "scaffold" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9099/" ]
250,583
<p>I'm trying to get all property names / values from an Outlook item. I have custom properties in addition to the default outlook item properties. I'm using redemption to get around the Outlook warnings but I'm having some problems with the GetNamesFromIDs method on a Redemption.RDOMail Item....</p> <p>I'm using my redemption session to get the message and trying to use the message to get the names of all the properties.</p> <pre><code>Dim rMessage as Redemption.RDOMail = _RDOSession.GetMessageFromID(EntryID, getPublicStoreID()) Dim propertyList As Redemption.PropList = someMessage.GetPropList(Nothing) For i As Integer = 1 To propertyList.Count + 1 Console.WriteLine(propertyList(i).ToString()) Console.WriteLine(someMessage.GetNamesFromIDs(________, propertyList(i))) Next </code></pre> <p>I'm not totally sure what to pass in as the first parameter to getNamesFromIDs. The definition of GetNamesFromIDs is as follows:</p> <pre><code>GetNamesFromIDs(MAPIProp as Object, PropTag as Integer) As Redemption.NamedProperty </code></pre> <p>I'm not totally sure what should be passed in as the MAPIProp object. I don't see this property referenced in the documentation. <a href="http://www.dimastr.com/redemption/rdo/MAPIProp.htm#properties" rel="nofollow noreferrer">http://www.dimastr.com/redemption/rdo/MAPIProp.htm#properties</a></p> <p>Any help or insight would be greatly appreciated.</p>
[ { "answer_id": 250967, "author": "robintw", "author_id": 1912, "author_profile": "https://Stackoverflow.com/users/1912", "pm_score": 3, "selected": true, "text": "scaffold" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1385358/" ]
250,597
<p>I have a WPF TreeView with just 1 level of items. The TreeView is data bound to an ObservableCollection of strings. How can I ensure that the same icon appears to the left of each node in the TreeView?</p>
[ { "answer_id": 253243, "author": "James Osborn", "author_id": 6686, "author_profile": "https://Stackoverflow.com/users/6686", "pm_score": 4, "selected": false, "text": "<Style TargetType=\"{x:Type TreeViewItem}\">\n <Setter Property=\"HeaderTemplate\">\n <Setter.Value>\n <DataTemplate>\n <StackPanel Orientation=\"Horizontal\">\n <Image Name=\"img\"\n Width=\"20\"\n Height=\"20\"\n Stretch=\"Fill\"\n Source=\"image.png\"/>\n <TextBlock Text=\"{Binding}\" Margin=\"5,0\" />\n </StackPanel>\n </DataTemplate>\n </Setter.Value>\n </Setter>\n</Style>\n" }, { "answer_id": 571053, "author": "Zack Peterson", "author_id": 83, "author_profile": "https://Stackoverflow.com/users/83", "pm_score": 4, "selected": false, "text": "<TreeView Name=\"TreeViewThings\" ItemsSource=\"{Binding}\">\n <TreeView.Resources>\n <HierarchicalDataTemplate DataType=\"{x:Type local:Thing}\"\n ItemsSource=\"{Binding Children}\">\n <StackPanel Orientation=\"Horizontal\" Margin=\"2\">\n <Image Source=\"Thing.png\"\n Width=\"16\"\n Height=\"16\"\n SnapsToDevicePixels=\"True\"/>\n <TextBlock Text=\"{Binding Path=Name}\" Margin=\"5,0\"/>\n </StackPanel>\n </HierarchicalDataTemplate>\n </TreeView.Resources>\n</TreeView>\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
250,599
<p>In the following code, used to get a list of products in a particular line, the command only returns results when I hard code (concatenate) <code>productLine</code> into the SQL. The parameter substitution never happens.</p> <pre><code> + "lineName = '@productLine' " + "and isVisible = 1 "; MySqlDataAdapter adap = new MySqlDataAdapter(sql, msc); adap.SelectCommand.Parameters.Add("@productLine", productLine); </code></pre>
[ { "answer_id": 250640, "author": "Ian G", "author_id": 31765, "author_profile": "https://Stackoverflow.com/users/31765", "pm_score": 0, "selected": false, "text": "+ \"lineName = '@productLine' \" \n + \"lineName = @productLine \" \n" }, { "answer_id": 250659, "author": "Omer van Kloeten", "author_id": 4979, "author_profile": "https://Stackoverflow.com/users/4979", "pm_score": 4, "selected": true, "text": " + \"lineName = ?productLine \" \n + \"and isVisible = 1 \";\n MySqlDataAdapter adap = new MySqlDataAdapter(sql, msc);\n adap.SelectCommand.Parameters.Add(\"?productLine\", productLine);\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
250,603
<p>I'm sure I'm going to have to write supporting javascript code to do this. I have an autocomplete extender set up that selects values from a database table, when a selection is made, i would like it to set the ID of the value selected to a hidden control. I can do that by handling a value change on the text box and making a select call to the database, Select idCompany from Companies Where CompanyName = "the text box value"; </p> <p>The most important thing is to constrain the values of the text box that is the targetcontrol for the autocomplete extender to ONLY use values from the autocomplete drop down. Is this possible with that control, is there examples somewhere? is there a better control to use (within the ajax control toolkit or standard .net framework - not a third party control)?</p> <p>I'm going to be trying to work out some javascript, but I'll be checking back to this question to see if anyone has some useful links. I've been googling this last night for quite a while.</p> <p>Update: I did not get an answer or any useful links, I've posted an almost acceptable user control that does what I want, with a few workable issues. </p>
[ { "answer_id": 265532, "author": "stephenbayer", "author_id": 18893, "author_profile": "https://Stackoverflow.com/users/18893", "pm_score": 3, "selected": true, "text": "<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"SelectCompany.ascx.cs\" Inherits=\"Controls_SelectCompany\" %>\n<%@ Register TagPrefix=\"ajaxToolkit\" Namespace=\"AjaxControlToolkit\" Assembly=\"AjaxControlToolkit\" %>\n<script language=\"javascript\" type=\"text/javascript\">\n var txtCompanyIDHiddenField = '<%= fldCompanyID.ClientID %>';\n var txtCompanyIDTextBox = '<%= txtCompany.ClientID %>';\n function getCompanyID() {\n if (document.getElementById(txtCompanyIDTextBox).value != \"\")\n CompanyService.GetCompanyIDByCompanyName(document.getElementById(txtCompanyIDTextBox).value, onCompanyIDSuccess, onCompanyIDFail);\n }\n function onCompanyIDSuccess(sender, e) {\n if (sender == -1)\n document.getElementById(txtCompanyIDTextBox).value = \"\";\n document.getElementById(txtCompanyIDHiddenField).value = sender;\n }\n function onCompanyIDFail(sender, e) {\n document.getElementById(txtCompanyIDTextBox).value = \"\";\n document.getElementById(txtCompanyIDHiddenField).value = \"-1\";\n }\n function onCompanySelected() {\n document.getElementById(txtCompanyIDTextBox).blur();\n }\n</script>\n<asp:TextBox ID=\"txtCompany\" runat=\"server\" onblur='getCompanyID()' \n/><ajaxToolkit:AutoCompleteExtender runat=\"server\" ID=\"aceCompany\" CompletionInterval=\"1000\" CompletionSetCount=\"10\"\n MinimumPrefixLength=\"2\" ServicePath=\"~/Company/CompanyService.asmx\" ServiceMethod=\"GetCompanyListBySearchString\"\n OnClientItemSelected=\"onCompanySelected\" TargetControlID=\"txtCompany\" />\n <asp:HiddenField ID=\"fldCompanyID\" runat=\"server\" Value=\"0\" />\n [System.ComponentModel.DefaultProperty(\"Text\")]\n[ValidationProperty(\"Text\")] \npublic partial class ApplicationControls_SelectCompany : System.Web.UI.UserControl\n\n{\npublic string Text\n{\n get { return txtCompany.Text; }\n set\n {\n txtCompany.Text = value;\n //this should probably be read only and set the value based off of ID to \n // make certain this is a valid Company\n }\n}\npublic int CompanyID\n{\n get\n {\n int ret = -1; Int32.TryParse(fldCompanyID.Value, out ret); return ret;\n }\n set\n {\n fldCompanyID.Value = value.ToString();\n //Todo: should set code to set the Text based on the ID to keep things straight\n }\n}\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18893/" ]
250,616
<p>A <a href="https://stackoverflow.com/questions/217618/construct-vs-sameasclassname-for-constructor-in-php">similar question discusses <code>__construct</code></a>, but I left it in my title for people searching who find this one.</p> <p>Apparently, __get and __set take a parameter that is the variable being gotten or set. However, you have to know the variable name (eg, know that the age of the person is $age instead of $myAge). So I don't see the point if you HAVE to know a variable name, especially if you are working with code that you aren't familiar with (such as a library).</p> <p>I found some pages that explain <a href="http://www.hudzilla.org/phpbook/read.php/6_14_2" rel="nofollow noreferrer"><code>__get()</code></a>, <a href="http://www.hudzilla.org/phpbook/read.php/6_14_3" rel="nofollow noreferrer"><code>__set()</code></a>, and <a href="http://www.hudzilla.org/phpbook/read.php/6_14_4" rel="nofollow noreferrer"><code>__call()</code></a>, but I still don't get why or when they are useful.</p>
[ { "answer_id": 250637, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "__set() __get() __get() __set() $user = ORM::factory('user', 1);\n$email = $user->email_address;\n __get() __set() __call()" }, { "answer_id": 250639, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 0, "selected": false, "text": "__set() __get() $myObject->foo = \"bar\";" }, { "answer_id": 250648, "author": "Aron Rotteveel", "author_id": 11568, "author_profile": "https://Stackoverflow.com/users/11568", "pm_score": 0, "selected": false, "text": "class Config\n{\n protected $_data = array();\n\n public function __set($key, $val)\n {\n $this->_data[$key] = $val;\n }\n\n public function __get($key)\n {\n return $this->_data[$key];\n }\n\n ...etc\n\n}\n $config = new Config();\n$config->foo = 'bar';\n\necho $config->foo; // returns 'bar'\n" }, { "answer_id": 250666, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 2, "selected": false, "text": "__get __set class Example\n{\n private $config = array('password' => 'pAsSwOrD');\n public function __get($name)\n {\n return $this->config[$name];\n }\n}\n" }, { "answer_id": 250668, "author": "JamShady", "author_id": 11905, "author_profile": "https://Stackoverflow.com/users/11905", "pm_score": 0, "selected": false, "text": "$conf = new Config();\n$conf->parent->child->grandchild = 'foo';\n function __get($key) {\n return new Config($key);\n}\n" }, { "answer_id": 250683, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 0, "selected": false, "text": "$obj->value = 'blah';\necho $obj->value;\n" }, { "answer_id": 250733, "author": "Michał Niedźwiedzki", "author_id": 2169, "author_profile": "https://Stackoverflow.com/users/2169", "pm_score": 2, "selected": false, "text": "__get __set __toString class View {\n\n public $templateFile;\n protected $properties = array();\n\n public function __set($property, $value) {\n $this->properties[$property] = $value;\n }\n\n public function __get($property) {\n return @$this->properties[$property];\n }\n\n public function __toString() {\n require_once 'smarty/libs/Smarty.class.php';\n $smarty = new Smarty();\n $smarty->template_dir = 'view';\n $smarty->compile_dir = 'smarty/compile';\n $smarty->config_dir = 'smarty/config';\n $smarty->cache_dir = 'smarty/cache';\n foreach ($this->properties as $property => $value) {\n $smarty->assign($property, $value);\n }\n return $smarty->fetch($this->templateFile);\n }\n\n}\n $index = new View();\n$index->templateFile = 'index.tpl';\n\n$topNav = new View();\n$topNav->templateFile = 'topNav.tpl';\n\n$index->topNav = $topNav;\n index.tpl <html>\n<head></head>\n<body>\n {$topNav}\n Welcome to Foobar Corporation.\n</body>\n</html>\n echo $index;" }, { "answer_id": 1673562, "author": "guliy", "author_id": 202581, "author_profile": "https://Stackoverflow.com/users/202581", "pm_score": 1, "selected": false, "text": "__set() __get() __set() __get()" }, { "answer_id": 14907264, "author": "Jay Bhatt", "author_id": 2076598, "author_profile": "https://Stackoverflow.com/users/2076598", "pm_score": 1, "selected": false, "text": "class Person { \n public $name;\n public function printProperties(){\n print_r(get_object_vars($this));\n }\n}\n\n$person = new Person();\n$person->name = 'Jay'; //This is valid\n$person->printProperties();\n$person->age = '26'; //This shouldn't work...but it does \n$person->printProperties();\n public function __set($name, $value){\n $classVar = get_object_vars($this);\n if(in_array($name, $classVar)){\n $this->$name = $value;\n }\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
250,622
<p>I'd trying to style my ComboBoxes to match the rest of the UI but I'm having problems with the IsMouseOver highlighting. It highlights with the color I specify for a second and then fades back to the default color, kind of a cool effect but not what I'm going for. Here is my style:</p> <pre><code>&lt;Style TargetType="ComboBox"&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="ComboBox.IsMouseOver" Value="True"&gt; &lt;Setter Property = "Background" Value="Red"/&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre> <p>What can I do to make the background color stay?</p>
[ { "answer_id": 252450, "author": "Todd White", "author_id": 30833, "author_profile": "https://Stackoverflow.com/users/30833", "pm_score": 3, "selected": true, "text": "<Style TargetType=\"{x:Type ComboBox}\">\n <Setter Property=\"Template\">\n <Setter.Value>\n <ControlTemplate TargetType=\"{x:Type ComboBox}\">\n <!-- Template Here -->\n </ControlTemplate>\n </Setter.Value>\n </Setter>\n</Style>\n" }, { "answer_id": 34533372, "author": "user1290865", "author_id": 1290865, "author_profile": "https://Stackoverflow.com/users/1290865", "pm_score": 0, "selected": false, "text": "<Style x:Key=\"ComboBoxReadonlyToggleButton\" TargetType=\"{x:Type ToggleButton}\">\n <Setter Property=\"OverridesDefaultStyle\" Value=\"true\"/>\n <Setter Property=\"IsTabStop\" Value=\"false\"/>\n <Setter Property=\"Focusable\" Value=\"false\"/>\n <Setter Property=\"ClickMode\" Value=\"Press\"/>\n <Setter Property=\"Background\" Value=\"Transparent\"/>\n <Setter Property=\"Template\">\n <Setter.Value>\n <ControlTemplate TargetType=\"{x:Type ToggleButton}\">\n <!-- Replace the ButtonChrome - this eliminated the following\n problem: When the mouse was moved over the ComboBox\n the color would change to the color defined in ___ but \n then would \n immediately change to the default Aero blue\n gradient background of 2 powder blue colors - \n Had to comment out the \n below code and replace it as shown\n <Themes:ButtonChrome x:Name=\"Chrome\" BorderBrush=\" {TemplateBinding BorderBrush}\" Background=\"{TemplateBinding Background}\" RenderMouseOver=\"{TemplateBinding IsMouseOver}\" RenderPressed=\"{TemplateBinding IsPressed}\" SnapsToDevicePixels=\"true\">\n <Grid HorizontalAlignment=\"Right\" Width=\"{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}\">\n <Path x:Name=\"Arrow\" Data=\"{StaticResource DownArrowGeometry}\" Fill=\"Black\" HorizontalAlignment=\"Center\" Margin=\"3,1,0,0\" VerticalAlignment=\"Center\"/>\n </Grid>\n </Themes:ButtonChrome>-->\n\n <!-- Here is the code to replace the ButtonChrome code -->\n <Border x:Name=\"Chrome\" BorderBrush=\"{TemplateBinding BorderBrush}\" Background=\"{TemplateBinding Background}\" SnapsToDevicePixels=\"true\">\n <Grid HorizontalAlignment=\"Right\" Width=\"{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}\">\n <Path x:Name=\"Arrow\" Data=\"{StaticResource DownArrowGeometry}\" Fill=\"Black\" HorizontalAlignment=\"Center\" Margin=\"3,1,0,0\" VerticalAlignment=\"Center\"/>\n </Grid>\n </Border>\n <!-- End of code to replace the Button Chrome -->\n <!-- Hover Code - Code that was added to change the ComboBox background \n color when the use hovers over it with the mouse -->\n<Trigger Property=\"IsMouseOver\" Value=\"True\">\n <Setter Property=\"Background\" Value=\"DarkOrange\"></Setter>\n</Trigger>\n<!-- Hover Code - End -->\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21186/" ]
250,643
<p>I want to attach a 'click' event handler to the first child of an element with ID 'foo' using <a href="http://en.wikipedia.org/wiki/JQuery" rel="nofollow noreferrer">jQuery</a>. I understand that the syntax for doing this is:</p> <pre><code>$('#foo:first-child').bind('click', function(event) { // I want to access the first child here }) </code></pre> <p>Within the handler body I want to access the element which caused the event to be fired. I've read somewhere that you can't simply refer to it via 'this', so how can I access it?</p>
[ { "answer_id": 250656, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "$(this).doStuff()\n" }, { "answer_id": 250661, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": true, "text": "$('#foo:first-child').bind('click', function(event) {\n alert(this === $('#foo:first-child')); // True\n this.style.color = \"red\"; // First child now has red text.\n})\n" }, { "answer_id": 250672, "author": "Svante Svenson", "author_id": 19707, "author_profile": "https://Stackoverflow.com/users/19707", "pm_score": 2, "selected": false, "text": "$(\"#foo:first-child\").click(function(event) {\n $(this).css(\"background\", \"pink\");\n});\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
250,652
<p>I use <code>_vimrc</code> to configure my vim 7.2 (windows) default settings. One setting "set number" will display line numbers on the left side. My vim background color is white (I cannot find setting for this. Maybe the default is white. Anyway I accept this setting).</p> <p>I would like the background color for line numbers to be Grey or dimmed color. What is the command I can put in my <code>_vimrc</code> to configure this default setting?</p>
[ { "answer_id": 250686, "author": "robert", "author_id": 32805, "author_profile": "https://Stackoverflow.com/users/32805", "pm_score": 7, "selected": true, "text": "highlight LineNr ctermfg=grey ctermbg=white\n" }, { "answer_id": 250964, "author": "David.Chu.ca", "author_id": 62776, "author_profile": "https://Stackoverflow.com/users/62776", "pm_score": 3, "selected": false, "text": "_vimrc highlight LineNr guibg=grey\n hi LineNr guibg=grey\n" }, { "answer_id": 33576970, "author": "Petur Subev", "author_id": 332124, "author_profile": "https://Stackoverflow.com/users/332124", "pm_score": 3, "selected": false, "text": "highlight LineNr guibg=NONE\n" }, { "answer_id": 41587510, "author": "sepehr", "author_id": 65732, "author_profile": "https://Stackoverflow.com/users/65732", "pm_score": 5, "selected": false, "text": ".vimrc highlight clear LineNr\n highlight clear SignColumn\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
250,679
<p>I'm currently using <a href="http://magpierss.sourceforge.net/" rel="noreferrer">Magpie RSS</a> but it sometimes falls over when the RSS or Atom feed isn't well formed. Are there any other options for parsing RSS and Atom feeds with PHP?</p>
[ { "answer_id": 251102, "author": "Brian Cline", "author_id": 32536, "author_profile": "https://Stackoverflow.com/users/32536", "pm_score": 7, "selected": false, "text": "class BlogPost\n{\n var $date;\n var $ts;\n var $link;\n\n var $title;\n var $text;\n}\n\nclass BlogFeed\n{\n var $posts = array();\n\n function __construct($file_or_url)\n {\n $file_or_url = $this->resolveFile($file_or_url);\n if (!($x = simplexml_load_file($file_or_url)))\n return;\n\n foreach ($x->channel->item as $item)\n {\n $post = new BlogPost();\n $post->date = (string) $item->pubDate;\n $post->ts = strtotime($item->pubDate);\n $post->link = (string) $item->link;\n $post->title = (string) $item->title;\n $post->text = (string) $item->description;\n\n // Create summary as a shortened body and remove images, \n // extraneous line breaks, etc.\n $post->summary = $this->summarizeText($post->text);\n\n $this->posts[] = $post;\n }\n }\n\n private function resolveFile($file_or_url) {\n if (!preg_match('|^https?:|', $file_or_url))\n $feed_uri = $_SERVER['DOCUMENT_ROOT'] .'/shared/xml/'. $file_or_url;\n else\n $feed_uri = $file_or_url;\n\n return $feed_uri;\n }\n\n private function summarizeText($summary) {\n $summary = strip_tags($summary);\n\n // Truncate summary line to 100 characters\n $max_len = 100;\n if (strlen($summary) > $max_len)\n $summary = substr($summary, 0, $max_len) . '...';\n\n return $summary;\n }\n}\n" }, { "answer_id": 19751841, "author": "PJunior", "author_id": 1987037, "author_profile": "https://Stackoverflow.com/users/1987037", "pm_score": 6, "selected": false, "text": "$feed = implode(file('http://yourdomains.com/feed.rss'));\n$xml = simplexml_load_string($feed);\n$json = json_encode($xml);\n$array = json_decode($json,TRUE);\n $feed = new DOMDocument();\n $feed->load('file.rss');\n $json = array();\n $json['title'] = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('title')->item(0)->firstChild->nodeValue;\n $json['description'] = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('description')->item(0)->firstChild->nodeValue;\n $json['link'] = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('link')->item(0)->firstChild->nodeValue;\n $items = $feed->getElementsByTagName('channel')->item(0)->getElementsByTagName('item');\n\n $json['item'] = array();\n $i = 0;\n\n foreach($items as $key => $item) {\n $title = $item->getElementsByTagName('title')->item(0)->firstChild->nodeValue;\n $description = $item->getElementsByTagName('description')->item(0)->firstChild->nodeValue;\n $pubDate = $item->getElementsByTagName('pubDate')->item(0)->firstChild->nodeValue;\n $guid = $item->getElementsByTagName('guid')->item(0)->firstChild->nodeValue;\n\n $json['item'][$key]['title'] = $title;\n $json['item'][$key]['description'] = $description;\n $json['item'][$key]['pubdate'] = $pubDate;\n $json['item'][$key]['guid'] = $guid; \n }\n\necho json_encode($json);\n" }, { "answer_id": 25813395, "author": "Vladimir Lukyanov", "author_id": 3159343, "author_profile": "https://Stackoverflow.com/users/3159343", "pm_score": 5, "selected": false, "text": "$i = 0; // counter\n$url = \"http://www.banki.ru/xml/news.rss\"; // url to parse\n$rss = simplexml_load_file($url); // XML parser\n\n// RSS items loop\n\nprint '<h2><img style=\"vertical-align: middle;\" src=\"'.$rss->channel->image->url.'\" /> '.$rss->channel->title.'</h2>'; // channel title + img with src\n\nforeach($rss->channel->item as $item) {\nif ($i < 10) { // parse only 10 items\n print '<a href=\"'.$item->link.'\">'.$item->title.'</a><br />';\n}\n\n$i++;\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25343/" ]
250,687
<p>I'm having trouble getting a rails app on Dreamhost's Passenger to see compiled libraries in my ~/opt/lib directory. I have to put them here because I don't have root access. </p> <p>I can boot up my app in ./script/console and it sees them libraries just fine because I updated my .bash_profile's <code>LD_LIBRARY_PATH</code> environment variable to include ~/opt/lib.</p> <p>I've tried putting <code>ENV['LD_LIBRARY_PATH'] = '~/opt/lib'</code> in my environment.rb file but it doesn't seem too help. I get the following error from Passenger when I navigate to my site: libodbcinst.so.1: cannot open shared object file: No such file or directory - /home/username/opt/lib/odbc.so</p> <p>Anyone have experience with this?</p> <p>Thanks</p>
[ { "answer_id": 423767, "author": "aussiegeek", "author_id": 51567, "author_profile": "https://Stackoverflow.com/users/51567", "pm_score": 1, "selected": false, "text": ".bashrc" }, { "answer_id": 431735, "author": "sammich", "author_id": 50276, "author_profile": "https://Stackoverflow.com/users/50276", "pm_score": 1, "selected": true, "text": "LD_LIBRARY_PATH .htaccess" }, { "answer_id": 7782806, "author": "Sasha", "author_id": 201377, "author_profile": "https://Stackoverflow.com/users/201377", "pm_score": 0, "selected": false, "text": "ldd /$HOME/your/custom/complied/library/file.so\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1766771/" ]
250,688
<p>I have the following HTML node structure:</p> <pre><code>&lt;div id="foo"&gt; &lt;div id="bar"&gt;&lt;/div&gt; &lt;div id="baz"&gt; &lt;div id="biz"&gt;&lt;/div&gt; &lt;/div&gt; &lt;span&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>How do I count the number of immediate children of <code>foo</code>, that are of type <code>div</code>? In the example above, the result should be two (<code>bar</code> and <code>baz</code>).</p>
[ { "answer_id": 250694, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 9, "selected": true, "text": "$(\"#foo > div\").length\n" }, { "answer_id": 250702, "author": "gizmo", "author_id": 9396, "author_profile": "https://Stackoverflow.com/users/9396", "pm_score": 3, "selected": false, "text": "$('#foo > div').size()\n" }, { "answer_id": 252348, "author": "Darko", "author_id": 32943, "author_profile": "https://Stackoverflow.com/users/32943", "pm_score": 5, "selected": false, "text": "$(\"#foo > div\") \n $(\"#foo > div\").size()\n $(\"#foo > div\").length\n" }, { "answer_id": 1937264, "author": "Andrew Perkins", "author_id": 235669, "author_profile": "https://Stackoverflow.com/users/235669", "pm_score": 2, "selected": false, "text": "var n_numTabs = $(\"#superpics div\").size();\n var n_numTabs = $(\"#superpics div\").length;\n" }, { "answer_id": 4358865, "author": "zholdas", "author_id": 272776, "author_profile": "https://Stackoverflow.com/users/272776", "pm_score": 3, "selected": false, "text": "$(\"#foo > div\").length\n" }, { "answer_id": 4429790, "author": "Alexandros Ioannou", "author_id": 540628, "author_profile": "https://Stackoverflow.com/users/540628", "pm_score": 1, "selected": false, "text": "$(\"div\", \"#superpics\").size();\n" }, { "answer_id": 7084389, "author": "manikanta", "author_id": 340290, "author_profile": "https://Stackoverflow.com/users/340290", "pm_score": 6, "selected": false, "text": "$('#foo').children().size() children() length size() $(\"#foo > div\").length $('#foo').children().length" }, { "answer_id": 7364918, "author": "HaxElit", "author_id": 182703, "author_profile": "https://Stackoverflow.com/users/182703", "pm_score": 3, "selected": false, "text": "var $foo = $('#foo');\nvar count = $foo[0].childElementCount\n" }, { "answer_id": 12864373, "author": "Kent Thomas", "author_id": 1741947, "author_profile": "https://Stackoverflow.com/users/1741947", "pm_score": 2, "selected": false, "text": "$(\"#superpics div\").children().length" }, { "answer_id": 15511389, "author": "John Alvarez", "author_id": 2188540, "author_profile": "https://Stackoverflow.com/users/2188540", "pm_score": 3, "selected": false, "text": "var divss = 0;\n$(function(){\n $(\"#foo div\").each(function(){\n divss++;\n\n });\n console.log(divss); \n}); \n<div id=\"foo\">\n <div id=\"bar\" class=\"1\"></div>\n <div id=\"baz\" class=\"1\"></div>\n <div id=\"bam\" class=\"1\"></div>\n</div>\n" }, { "answer_id": 19539030, "author": "Abdennour TOUMI", "author_id": 747579, "author_profile": "https://Stackoverflow.com/users/747579", "pm_score": 4, "selected": false, "text": "$('#foo').children('div').length\n" }, { "answer_id": 58214614, "author": "talent makhanya", "author_id": 8607598, "author_profile": "https://Stackoverflow.com/users/8607598", "pm_score": -1, "selected": false, "text": "$(\"#foo > div\")[0].children.length\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
250,690
<p>I'm looking for a good JavaScript RegEx to convert names to proper cases. For example:</p> <pre><code>John SMITH = John Smith Mary O'SMITH = Mary O'Smith E.t MCHYPHEN-SMITH = E.T McHyphen-Smith John Middlename SMITH = John Middlename SMITH </code></pre> <p>Well you get the idea.</p> <p>Anyone come up with a comprehensive solution?</p>
[ { "answer_id": 250772, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 1, "selected": false, "text": "Regex fixnames = new Regex(\"(Ma?C)?(\\w)(\\w*)(\\W*)\");\nstring newName = fixnames.Replace(badName, NameFixer);\n\n\nstatic public string NameFixer(Match match) \n{\n string mc = \"\";\n if (match.Groups[1].Captures.Count > 0)\n {\n if (match.Groups[1].Captures[0].Length == 3)\n mc = \"Mac\";\n else\n mc = \"Mc\";\n }\n\n return \n mc\n +match.Groups[2].Captures[0].Value.ToUpper()\n +match.Groups[3].Captures[0].Value.ToLower()\n +match.Groups[4].Captures[0].Value;\n}\n" }, { "answer_id": 250785, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 3, "selected": true, "text": "function fix_name(name) {\n var replacer = function (whole,prefix,word) {\n ret = [];\n if (prefix) {\n ret.push(prefix.charAt(0).toUpperCase());\n ret.push(prefix.substr(1).toLowerCase());\n }\n ret.push(word.charAt(0).toUpperCase());\n ret.push(word.substr(1).toLowerCase());\n return ret.join('');\n }\n var pattern = /\\b(ma?c)?([a-z]+)/ig;\n return name.replace(pattern, replacer);\n}\n" }, { "answer_id": 251755, "author": "Robert Krimen", "author_id": 25171, "author_profile": "https://Stackoverflow.com/users/25171", "pm_score": 1, "selected": false, "text": "KEITH Keith\nLEIGH-WILLIAMS Leigh-Williams\nMCCARTHY McCarthy\nO'CALLAGHAN O'Callaghan\nST. JOHN St. John\nVON STREIT von Streit\nVAN DYKE van Dyke\nAP LLWYD DAFYDD ap Llwyd Dafydd\nhenry viii Henry VIII\nlouis xiv Louis XIV\n sub nc {\n\n croak \"Usage: nc [[\\\\]\\$SCALAR]\"\n if scalar @_ > 1 or ( ref $_[0] and ref $_[0] ne 'SCALAR' ) ;\n\n local( $_ ) = @_ if @_ ;\n $_ = ${$_} if ref( $_ ) ; # Replace reference with value.\n\n $_ = lc ; # Lowercase the lot.\n s{ \\b (\\w) }{\\u$1}gox ; # Uppercase first letter of every word.\n s{ (\\'\\w) \\b }{\\L$1}gox ; # Lowercase 's.\n\n # Name case Mcs and Macs - taken straight from NameParse.pm incl. comments.\n # Exclude names with 1-2 letters after prefix like Mack, Macky, Mace\n # Exclude names ending in a,c,i,o, or j are typically Polish or Italian\n\n if ( /\\bMac[A-Za-z]{2,}[^aciozj]\\b/o or /\\bMc/o ) {\n s/\\b(Ma?c)([A-Za-z]+)/$1\\u$2/go ;\n\n # Now correct for \"Mac\" exceptions\n s/\\bMacEvicius/Macevicius/go ; # Lithuanian\n s/\\bMacHado/Machado/go ; # Portuguese\n s/\\bMacHar/Machar/go ;\n s/\\bMacHin/Machin/go ;\n s/\\bMacHlin/Machlin/go ;\n s/\\bMacIas/Macias/go ; \n s/\\bMacIulis/Maciulis/go ; \n s/\\bMacKie/Mackie/go ;\n s/\\bMacKle/Mackle/go ;\n s/\\bMacKlin/Macklin/go ;\n s/\\bMacQuarie/Macquarie/go ;\n s/\\bMacOmber/Macomber/go ;\n s/\\bMacIn/Macin/go ;\n s/\\bMacKintosh/Mackintosh/go ;\n s/\\bMacKen/Macken/go ;\n s/\\bMacHen/Machen/go ;\n s/\\bMacisaac/MacIsaac/go ;\n s/\\bMacHiel/Machiel/go ;\n s/\\bMacIol/Maciol/go ;\n s/\\bMacKell/Mackell/go ;\n s/\\bMacKlem/Macklem/go ;\n s/\\bMacKrell/Mackrell/go ;\n s/\\bMacLin/Maclin/go ;\n s/\\bMacKey/Mackey/go ;\n s/\\bMacKley/Mackley/go ;\n s/\\bMacHell/Machell/go ;\n s/\\bMacHon/Machon/go ;\n }\n s/Macmurdo/MacMurdo/go ;\n\n # Fixes for \"son (daughter) of\" etc. in various languages.\n s{ \\b Al(?=\\s+\\w) }{al}gox ; # al Arabic or forename Al.\n s{ \\b Ap \\b }{ap}gox ; # ap Welsh.\n s{ \\b Ben(?=\\s+\\w) }{ben}gox ; # ben Hebrew or forename Ben.\n s{ \\b Dell([ae])\\b }{dell$1}gox ; # della and delle Italian.\n s{ \\b D([aeiu]) \\b }{d$1}gox ; # da, de, di Italian; du French.\n s{ \\b De([lr]) \\b }{de$1}gox ; # del Italian; der Dutch/Flemish.\n s{ \\b El \\b }{el}gox unless $SPANISH ; # el Greek or El Spanish.\n s{ \\b La \\b }{la}gox unless $SPANISH ; # la French or La Spanish.\n s{ \\b L([eo]) \\b }{l$1}gox ; # lo Italian; le French.\n s{ \\b Van(?=\\s+\\w) }{van}gox ; # van German or forename Van.\n s{ \\b Von \\b }{von}gox ; # von Dutch/Flemish\n\n # Fixes for roman numeral names, e.g. Henry VIII, up to 89, LXXXIX\n s{ \\b ( (?: [Xx]{1,3} | [Xx][Ll] | [Ll][Xx]{0,3} )?\n (?: [Ii]{1,3} | [Ii][VvXx] | [Vv][Ii]{0,3} )? ) \\b }{\\U$1}gox ;\n\n $_ ;\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/262775/" ]
250,692
<p>I'm building a class library that will have some public &amp; private methods. I want to be able to unit test the private methods (mostly while developing, but also it could be useful for future refactoring).</p> <p>What is the correct way to do this?</p>
[ { "answer_id": 250703, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 2, "selected": false, "text": "internal InternalsVisibleToAttribute" }, { "answer_id": 250748, "author": "Jason Jackson", "author_id": 13103, "author_profile": "https://Stackoverflow.com/users/13103", "pm_score": 6, "selected": false, "text": "...\n\nprotected void APrivateFunction()\n{\n ...\n}\n\n...\n ...\n\n[Test]\npublic void TestAPrivateFunction()\n{\n APrivateFunction();\n //or whatever testing code you want here\n}\n\n...\n" }, { "answer_id": 250768, "author": "Marcus King", "author_id": 19840, "author_profile": "https://Stackoverflow.com/users/19840", "pm_score": 3, "selected": false, "text": "[System.Diagnostics.DebuggerStepThrough()]\n [System.CodeDom.Compiler.GeneratedCodeAttribute(\"Microsoft.VisualStudio.TestTools.UnitTestGeneration\", \"1.0.0.0\")]\n internal class BaseAccessor\n {\n\n protected Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject m_privateObject;\n\n protected BaseAccessor(object target, Microsoft.VisualStudio.TestTools.UnitTesting.PrivateType type)\n {\n m_privateObject = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(target, type);\n }\n\n protected BaseAccessor(Microsoft.VisualStudio.TestTools.UnitTesting.PrivateType type)\n :\n this(null, type)\n {\n }\n\n internal virtual object Target\n {\n get\n {\n return m_privateObject.Target;\n }\n }\n\n public override string ToString()\n {\n return this.Target.ToString();\n }\n\n public override bool Equals(object obj)\n {\n if (typeof(BaseAccessor).IsInstanceOfType(obj))\n {\n obj = ((BaseAccessor)(obj)).Target;\n }\n return this.Target.Equals(obj);\n }\n\n public override int GetHashCode()\n {\n return this.Target.GetHashCode();\n }\n }\n [System.Diagnostics.DebuggerStepThrough()]\n[System.CodeDom.Compiler.GeneratedCodeAttribute(\"Microsoft.VisualStudio.TestTools.UnitTestGeneration\", \"1.0.0.0\")]\ninternal class SomeClassAccessor : BaseAccessor\n{\n\n protected static Microsoft.VisualStudio.TestTools.UnitTesting.PrivateType m_privateType = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateType(typeof(global::Namespace.SomeClass));\n\n internal SomeClassAccessor(global::Namespace.Someclass target)\n : base(target, m_privateType)\n {\n }\n\n internal static string STATIC_STRING\n {\n get\n {\n string ret = ((string)(m_privateType.GetStaticField(\"STATIC_STRING\")));\n return ret;\n }\n set\n {\n m_privateType.SetStaticField(\"STATIC_STRING\", value);\n }\n }\n\n internal int memberVar {\n get\n {\n int ret = ((int)(m_privateObject.GetField(\"memberVar\")));\n return ret;\n }\n set\n {\n m_privateObject.SetField(\"memberVar\", value);\n }\n }\n\n internal int PrivateMethodName(int paramName)\n {\n object[] args = new object[] {\n paramName};\n int ret = (int)(m_privateObject.Invoke(\"PrivateMethodName\", new System.Type[] {\n typeof(int)}, args)));\n return ret;\n }\n" }, { "answer_id": 252823, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 2, "selected": false, "text": "CC -Dprivate=public\n -Dfoo=bar #define foo bar" }, { "answer_id": 1320874, "author": "Carl Bergquist", "author_id": 79941, "author_profile": "https://Stackoverflow.com/users/79941", "pm_score": 2, "selected": false, "text": "Reflector dogReflector = new Reflector(new Dog());\ndogReflector.Invoke(\"DreamAbout\", DogDream.Food);\n dogReflector.GetProperty(\"Age\");\n" }, { "answer_id": 2902862, "author": "amazedsaint", "author_id": 45956, "author_profile": "https://Stackoverflow.com/users/45956", "pm_score": 4, "selected": false, "text": " //Note that the wrapper is dynamic\n dynamic wrapper = AccessPrivateWrapper.FromType\n (typeof(SomeKnownClass).Assembly,\"ClassWithPrivateConstructor\");\n\n //Access the private members\n wrapper.PrivateMethodInPrivateClass();\n" }, { "answer_id": 4052474, "author": "Seven", "author_id": 335478, "author_profile": "https://Stackoverflow.com/users/335478", "pm_score": 7, "selected": false, "text": "// Wrap an already existing instance\nPrivateObject accessor = new PrivateObject( objectInstanceToBeWrapped );\n\n// Retrieve a private field\nMyReturnType accessiblePrivateField = (MyReturnType) accessor.GetField( \"privateFieldName\" );\n\n// Call a private method\naccessor.Invoke( \"PrivateMethodName\", new Object[] {/* ... */} );\n" }, { "answer_id": 9885377, "author": "Unknown", "author_id": 1280656, "author_profile": "https://Stackoverflow.com/users/1280656", "pm_score": 4, "selected": false, "text": "PrivateObject PrivateObject obj= new PrivateObject(PrivateClass);\n//now with this obj you can call the private method of PrivateCalss.\nobj.PrivateMethod(\"Parameters\");\n PrivateClass obj = new PrivateClass(); // Class containing private obj\nType t = typeof(PrivateClass); \nvar x = t.InvokeMember(\"PrivateFunc\", \n BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | \n BindingFlags.Instance, null, obj, new object[] { 5 });\n" }, { "answer_id": 10641115, "author": "Chuck Savage", "author_id": 353147, "author_profile": "https://Stackoverflow.com/users/353147", "pm_score": 1, "selected": false, "text": "private string[] SplitInternal()\n{\n return Regex.Matches(Format, @\"([^/\\[\\]]|\\[[^]]*\\])+\")\n .Cast<Match>()\n .Select(m => m.Value)\n .Where(s => !string.IsNullOrEmpty(s))\n .ToArray();\n}\n /// <summary>\n///A test for SplitInternal\n///</summary>\n[TestMethod()]\n[DeploymentItem(\"Git XmlLib vs2008.dll\")]\npublic void SplitInternalTest()\n{\n string path = \"pair[path/to/@Key={0}]/Items/Item[Name={1}]/Date\";\n object[] values = new object[] { 2, \"Martin\" };\n XPathString xp = new XPathString(path, values);\n\n PrivateObject param0 = new PrivateObject(xp);\n XPathString_Accessor target = new XPathString_Accessor(param0);\n string[] expected = new string[] {\n \"pair[path/to/@Key={0}]\",\n \"Items\",\n \"Item[Name={1}]\",\n \"Date\"\n };\n string[] actual;\n actual = target.SplitInternal();\n CollectionAssert.AreEqual(expected, actual);\n}\n" }, { "answer_id": 25980889, "author": "kiriloff", "author_id": 1141493, "author_profile": "https://Stackoverflow.com/users/1141493", "pm_score": 1, "selected": false, "text": "protected public" }, { "answer_id": 31462998, "author": "Damon Hogan", "author_id": 2801033, "author_profile": "https://Stackoverflow.com/users/2801033", "pm_score": 2, "selected": false, "text": " /**\n *\n * @var Class_name_of_class_you_want_to_test_private_methods_in\n * note: the actual class and the private variable to store the \n * class instance in, should at least be different case so that\n * they do not get confused in the code. Here the class name is\n * is upper case while the private instance variable is all lower\n * case\n */\n private $class_name_of_class_you_want_to_test_private_methods_in;\n\n /**\n * This uses reflection to be able to get private methods to test\n * @param $methodName\n * @return ReflectionMethod\n */\n protected static function getMethod($methodName) {\n $class = new ReflectionClass('Class_name_of_class_you_want_to_test_private_methods_in');\n $method = $class->getMethod($methodName);\n $method->setAccessible(true);\n return $method;\n }\n\n /**\n * Uses reflection class to call private methods and get return values.\n * @param $methodName\n * @param array $params\n * @return mixed\n *\n * usage: $this->_callMethod('_someFunctionName', array(param1,param2,param3));\n * {params are in\n * order in which they appear in the function declaration}\n */\n protected function _callMethod($methodName, $params=array()) {\n $method = self::getMethod($methodName);\n return $method->invokeArgs($this->class_name_of_class_you_want_to_test_private_methods_in, $params);\n }\n" }, { "answer_id": 32817853, "author": "Alex H", "author_id": 4021938, "author_profile": "https://Stackoverflow.com/users/4021938", "pm_score": 1, "selected": false, "text": " /// <summary>\n /// This Method is private.\n /// </summary>\n#if DEBUG\n public\n#else\n private\n#endif\n static string MyPrivateMethod()\n {\n return \"false\";\n }\n private" }, { "answer_id": 34319555, "author": "Erick Stone", "author_id": 2683840, "author_profile": "https://Stackoverflow.com/users/2683840", "pm_score": 3, "selected": false, "text": "public class ReflectionTools\n{\n // If the class is non-static\n public static Object InvokePrivate(Object objectUnderTest, string method, params object[] args)\n {\n Type t = objectUnderTest.GetType();\n return t.InvokeMember(method,\n BindingFlags.InvokeMethod |\n BindingFlags.NonPublic |\n BindingFlags.Instance |\n BindingFlags.Static,\n null,\n objectUnderTest,\n args);\n }\n // if the class is static\n public static Object InvokePrivate(Type typeOfObjectUnderTest, string method, params object[] args)\n {\n MemberInfo[] members = typeOfObjectUnderTest.GetMembers(BindingFlags.NonPublic | BindingFlags.Static);\n foreach(var member in members)\n {\n if (member.Name == method)\n {\n return typeOfObjectUnderTest.InvokeMember(method, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod, null, typeOfObjectUnderTest, args);\n }\n }\n return null;\n }\n}\n Assert.AreEqual( \n ReflectionTools.InvokePrivate(\n typeof(StaticClassOfMethod), \n \"PrivateMethod\"), \n \"Expected Result\");\n\nAssert.AreEqual( \n ReflectionTools.InvokePrivate(\n new ClassOfMethod(), \n \"PrivateMethod\"), \n \"Expected Result\");\n" }, { "answer_id": 43542131, "author": "vsapiha", "author_id": 237654, "author_profile": "https://Stackoverflow.com/users/237654", "pm_score": 2, "selected": false, "text": "Class target = new Class();\nPrivateObject obj = new PrivateObject(target);\nvar retVal = obj.Invoke(\"PrivateMethod\");\nAssert.AreEqual(retVal);\n" }, { "answer_id": 48508719, "author": "Amit Kaneria", "author_id": 5166818, "author_profile": "https://Stackoverflow.com/users/5166818", "pm_score": -1, "selected": false, "text": "public class ClassToTest \n{\n public void methodToTest()\n {\n Integer integerInstance = new Integer(0);\n boolean returnValue= methodToMock(integerInstance);\n if(returnValue)\n {\n System.out.println(\"methodToMock returned true\");\n }\n else\n {\n System.out.println(\"methodToMock returned true\");\n }\n System.out.println();\n }\n private boolean methodToMock(int value)\n {\n return true;\n }\n}\n public class ClassToTestTest{\n\n @Test\n public void testMethodToTest(){\n\n new Mockup<ClassToTest>(){\n @Mock\n private boolean methodToMock(int value){\n return true;\n }\n };\n\n .... \n\n }\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6522/" ]
250,700
<p>I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is run like:</p> <pre><code>sudo mod args </code></pre> <p>where mod is a perl script; so in python I would do </p> <pre><code>proc = Popen(['sudo', 'mod', '-p', '-c', 'noresource', '-u', 'dtt', '-Q'], stderr=PIPE, stdout=PIPE, stdin=PIPE) </code></pre> <p>The problem is that this mod script needs a few questions answered. For this I thought that the traditional </p> <pre><code>(stdout, stderr) = proc.communicate(input='y') </code></pre> <p>would work. I don't think it's working because the process that Popen is controlling is sudo, not the mod script that is asking the question. Is there any way to communicate with the mod script and still run it through sudo?</p>
[ { "answer_id": 250804, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 1, "selected": false, "text": "sudo" }, { "answer_id": 250819, "author": "Rômulo Ceccon", "author_id": 23193, "author_profile": "https://Stackoverflow.com/users/23193", "pm_score": 2, "selected": false, "text": "sudo Popen sudo Popen" }, { "answer_id": 252100, "author": "miya", "author_id": 293, "author_profile": "https://Stackoverflow.com/users/293", "pm_score": 3, "selected": true, "text": "import pexpect\nchild = pexpect.spawn ('sudo mod -p -c noresource -u dtt -Q')\nchild.expect ('First question:')\nchild.sendline ('Y')\nchild.expect ('Second question:')\nchild.sendline ('Yup')\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7949/" ]
250,713
<p>Why would a stored procedure that returns a table with 9 columns, 89 rows using this code take 60 seconds to execute (.NET 1.1) when it takes &lt; 1 second to run in SQL Server Management Studio? It's being run on the local machine so little/no network latency, fast dev machine</p> <pre><code>Dim command As SqlCommand = New SqlCommand(procName, CreateConnection()) command.CommandType = CommandType.StoredProcedure command.CommandTimeout = _commandTimeOut Try Dim adapter As new SqlDataAdapter(command) Dim i as Integer For i=0 to parameters.Length-1 command.Parameters.Add(parameters(i)) Next adapter.Fill(tableToFill) adapter.Dispose() Finally command.Dispose() End Try </code></pre> <p>my paramter array is typed (for this SQL it's only a single parameter)</p> <pre><code>parameters(0) = New SqlParameter("@UserID", SqlDbType.BigInt, 0, ParameterDirection.Input, True, 19, 0, "", DataRowVersion.Current, userID) </code></pre> <p>The Stored procedure is only a select statement like so:</p> <pre><code>ALTER PROC [dbo].[web_GetMyStuffFool] (@UserID BIGINT) AS SELECT Col1, Col2, Col3, Col3, Col3, Col3, Col3, Col3, Col3 FROM [Table] </code></pre>
[ { "answer_id": 250961, "author": "HTTP 410", "author_id": 13118, "author_profile": "https://Stackoverflow.com/users/13118", "pm_score": 7, "selected": true, "text": "SET ARITHABORT OFF SET ARITHABORT OFF ARITHABORT sys.dm_exec_cached_plans DBCC DROPCLEANBUFFERS\nDBCC FREEPROCCACHE\n" }, { "answer_id": 492868, "author": "Steve Wright", "author_id": 3256, "author_profile": "https://Stackoverflow.com/users/3256", "pm_score": 3, "selected": false, "text": "EXEC <databasename>..sp_MSforeachtable @command1='DBCC DBREINDEX (''*'')', @replacechar='*'\n-- Replace <databasename> with the name of your database\n SET ARITHABORT OFF\nEXEC [dbo].[web_GetMyStuffFool] @UserID=1\nSET ARITHABORT ON\n MyConnection.Execute \"SET ARITHABORT ON\"\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3256/" ]
250,717
<p>I'm trying to write a log parsing script to extract failed events. I can pull these with grep:</p> <pre><code>$ grep -A5 "FAILED" log.txt 2008-08-19 17:50:07 [7052] [14] DEBUG: data: 3a 46 41 49 4c 45 44 20 20 65 72 72 3a 30 32 33 :FAILED err:023 2008-08-19 17:50:07 [7052] [14] DEBUG: data: 20 74 65 78 74 3a 20 00 text: . 2008-08-19 17:50:07 [7052] [14] DEBUG: Octet string dump ends. 2008-08-19 17:50:07 [7052] [14] DEBUG: SMPP PDU dump ends. 2008-08-19 17:50:07 [7052] [14] DEBUG: SMPP[test] handle_pdu, got DLR 2008-08-19 17:50:07 [7052] [14] DEBUG: DLR[internal]: Looking for DLR smsc=test, ts=1158667543, dst=447872123456, type=2 -- 2008-08-19 17:50:07 [7052] [8] DEBUG: data: 3a 46 41 49 4c 45 44 20 20 65 72 72 3a 30 32 34 :FAILED err:024 2008-08-19 17:50:07 [7052] [8] DEBUG: data: 20 74 65 78 74 3a 20 00 text: . 2008-08-19 17:50:07 [7052] [8] DEBUG: Octet string dump ends. 2008-08-19 17:50:07 [7052] [8] DEBUG: SMPP PDU dump ends. 2008-08-19 17:50:07 [7052] [8] DEBUG: SMPP[test] handle_pdu, got DLR 2008-08-19 17:50:07 [7052] [8] DEBUG: DLR[internal]: Looking for DLR smsc=test, ts=1040097716, dst=447872987654, type=2 </code></pre> <p>What I'm interested in is, for each block, the error code (i.e. the "023" part of ":FAILED err:023" on the first line) and the dst number (i.e."447872123456" from "dst=447872123456" on the last line.)</p> <p>Can anyone help with a shell one-liner to extract those two values, or provide some hints as to how I should approach this?</p>
[ { "answer_id": 250761, "author": "Michael Gundlach", "author_id": 4105, "author_profile": "https://Stackoverflow.com/users/4105", "pm_score": 3, "selected": true, "text": "grep -A 5 FAILED log.txt | \\ # Get FAILED and dst and other lines\n egrep '(FAILED|dst=)' | \\ # Just the FAILED/dst lines\n egrep -o \"err:[0-9]*|dst=[0-9]*\" | \\ # Just the err: and dst= phrases\n cut -d':' -f 2 | \\ # Strip \"err:\" from err: lines\n cut -d '=' -f 2 | \\ # Strip \"dst=\" from dst= lines\n xargs -n 2 # Combine pairs of numbers\n\n023 447872123456\n024 447872987654\n" }, { "answer_id": 250770, "author": "bltxd", "author_id": 11892, "author_profile": "https://Stackoverflow.com/users/11892", "pm_score": 0, "selected": false, "text": "filter.rb #! /usr/bin/env ruby\nFile.read(ARGV.first).scan(/:FAILED\\s+err:(\\d+).*?, dst=(\\d+),/m).each do |err, dst|\n puts \"#{err} #{dst}\"\nend\n ruby filter.rb my_log_file.txt\n 023 447872123456\n024 447872987654\n" }, { "answer_id": 266152, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "grep -A5 \"FAILED\" log.txt | awk '$24~/err/ {print $24} $12~/dst/{print $12}' error.txt\n\nerr:023\ndst=447872123456,\nerr:024\ndst=447872987654,\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
250,718
<p>If I grant execute permissions to a role via</p> <pre><code>GRANT EXECUTE ON [DBO].[MYPROC] TO MY_ROLE </code></pre> <p>what's the equivalent syntax to remove them?</p>
[ { "answer_id": 250724, "author": "Godeke", "author_id": 28006, "author_profile": "https://Stackoverflow.com/users/28006", "pm_score": 4, "selected": false, "text": "DENY EXECUTE ON [DBO].[MYPROC] TO MY_ROLE\n REVOKE EXECUTE ON [DBO].[MYPROC] TO MY_ROLE\n" }, { "answer_id": 250726, "author": "Marcus King", "author_id": 19840, "author_profile": "https://Stackoverflow.com/users/19840", "pm_score": 1, "selected": false, "text": "DENY EXECUTE ON [DBO].[MYPROC] TO MY_ROLE\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
250,755
<p>I'm trying to export a Crystal Report to an HTML file, but when I call the Export method, I immediately get this error:</p> <blockquote> <p><strong>Source</strong>: Crystal Reports ActiveX Designer </p> <p><strong>Description</strong>: Failed to export the report.</p> </blockquote> <p>I have tried both crEFTHTML40 and crEFTHTML32Standard as export format types - and both result in the same error.</p> <p>Here is a highly simplified version of what I'm doing:</p> <pre><code>Dim objCRReport As CRAXDRT.Report [...] objCRReport.ExportOptions.FormatType = 32 'crEFTHTML40 objCRReport.ExportOptions.DestinationType = 1 'crEDTDiskFile objCRReport.ExportOptions.DiskFileName = "C:\reportInHtmlFormat.html" objCRReport.Export False '&lt;--- "Failed to export the report" error here </code></pre> <p>Please note that I am referencing the "Crystal Reports 9 ActiveX Designer Runtime Library" specifically.</p>
[ { "answer_id": 269715, "author": "user35193", "author_id": 35193, "author_profile": "https://Stackoverflow.com/users/35193", "pm_score": 2, "selected": true, "text": "[...] Dim objCRReport As CRAXDRT.Report\n\n'***********************************\nDim objCRApp As New CRAXDRT.Application\n\nobjCRReport = objCRApp.OpenReport(\"<YOUR REPORT FILENAME>\", 1)\n'***********************************\n\n[...]\nobjCRReport.ExportOptions.FormatType = 32 'crEFTHTML40\nobjCRReport.ExportOptions.DestinationType = 1 'crEDTDiskFile\nobjCRReport.ExportOptions.DiskFileName = \"C:\\reportInHtmlFormat.html\"\nobjCRReport.Export False '<--- \"Failed to export the report\" error here\n" }, { "answer_id": 2149646, "author": "ANeto", "author_id": 260378, "author_profile": "https://Stackoverflow.com/users/260378", "pm_score": 0, "selected": false, "text": "HTMLFileName objCRReport.ExportOptions.HTMLFileName = \"C:\\reportInHtmlFormat.html\"\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21263/" ]
250,757
<p>I'm writing an application using Qt4.</p> <p>I need to download a very short text file from a given http address.</p> <p>The file is short and is needed for my app to be able to continue, so I would like to make sure the download is blocking (or will timeout after a few seconds if the file in not found/not available).</p> <p>I wanted to use QHttp::get(), but this is a non-blocking method.</p> <p>I thought I could use a thread : my app would start it, and wait for it to finish. The thread would handle the download and quit when the file is downloaded or after a timeout.</p> <p>But I cannot make it work :</p> <pre><code>class JSHttpGetterThread : public QThread { Q_OBJECT public: JSHttpGetterThread(QObject* pParent = NULL); ~JSHttpGetterThread(); virtual void run() { m_pHttp = new QHttp(this); connect(m_pHttp, SIGNAL(requestFinished(int, bool)), this, SLOT(onRequestFinished(int, bool))); m_pHttp-&gt;setHost("127.0.0.1"); m_pHttp-&gt;get("Foo.txt", &amp;m_GetBuffer); exec(); } const QString&amp; getDownloadedFileContent() const { return m_DownloadedFileContent; } private: QHttp* m_pHttp; QBuffer m_GetBuffer; QString m_DownloadedFileContent; private slots: void onRequestFinished(int Id, bool Error) { m_DownloadedFileContent = ""; m_DownloadedFileContent.append(m_GetBuffer.buffer()); } }; </code></pre> <p>In the method creating the thread to initiate the download, here is what I'm doing :</p> <pre><code>JSHttpGetterThread* pGetter = new JSHttpGetterThread(this); pGetter-&gt;start(); pGetter-&gt;wait(); </code></pre> <p>But that doesn't work and my app keeps waiting. It looks lit the slot 'onRequestFinished' is never called.</p> <p>Any idea ?</p> <p>Is there a better way to do what I'm trying to do ?</p>
[ { "answer_id": 250950, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "QThread::quit() exit()" }, { "answer_id": 251631, "author": "Dusty Campbell", "author_id": 2174, "author_profile": "https://Stackoverflow.com/users/2174", "pm_score": -1, "selected": false, "text": "JSHttpGetterThread* pGetter = new JSHttpGetterThread(this);\npGetter->start();\npGetter->wait(10000); //give the thread 10 seconds to download\n" }, { "answer_id": 252821, "author": "David Dibben", "author_id": 5022, "author_profile": "https://Stackoverflow.com/users/5022", "pm_score": 4, "selected": true, "text": "processEvents while (notFinished) {\n qApp->processEvents(QEventLoop::WaitForMore | QEventLoop::ExcludeUserInput);\n}\n notFinished onRequestFinished ExcludeUserInput" }, { "answer_id": 258496, "author": "Jérôme", "author_id": 2796, "author_profile": "https://Stackoverflow.com/users/2796", "pm_score": 1, "selected": false, "text": "class BlockingDownloader : public QObject\n{\n Q_OBJECT\npublic:\n BlockingDownloaderBlockingDownloader()\n {\n m_pHttp = new QHttp(this);\n connect(m_pHttp, SIGNAL(requestFinished(int, bool)), this, SLOT(onRequestFinished(int, bool)));\n }\n\n ~BlockingDownloader()\n {\n delete m_pHttp;\n }\n\n QString getFileContent()\n {\n m_pHttp->setHost(\"www.xxx.com\");\n m_DownloadId = m_pHttp->get(\"/myfile.txt\", &m_GetBuffer);\n\n QTimer::singleShot(m_TimeOutTime, this, SLOT(onTimeOut()));\n while (!m_FileIsDownloaded)\n {\n qApp->processEvents(QEventLoop::WaitForMoreEvents | QEventLoop::ExcludeUserInputEvents);\n }\n return m_DownloadedFileContent;\n }\n\nprivate slots:\n void BlockingDownloader::onRequestFinished(int Id, bool Error)\n {\n if (Id == m_DownloadId)\n {\n m_DownloadedFileContent = \"\";\n m_DownloadedFileContent.append(m_GetBuffer.buffer());\n m_FileIsDownloaded = true;\n }\n }\n\n void BlockingDownloader::onTimeOut()\n {\n m_FileIsDownloaded = true;\n }\n\nprivate:\n QHttp* m_pHttp;\n bool m_FileIsDownloaded;\n QBuffer m_GetBuffer;\n QString m_DownloadedFileContent;\n int m_DownloadId;\n};\n" }, { "answer_id": 265526, "author": "Phil Hannent", "author_id": 24459, "author_profile": "https://Stackoverflow.com/users/24459", "pm_score": 3, "selected": false, "text": "httpGetFile= new QHttp();\nconnect(httpGetFile, SIGNAL(done(bool)), this, SLOT(processHttpGetFile(bool)));\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2796/" ]
250,766
<p>I am using a Windows XP Home Edition. I need to install a few extensions to PHP -- memcache, APC, .etc. And I would very much like to use PECL to make this happen. The problem is PECL takes it for granted that I will have certain programs on my computer. On another post, I read, for instance, that you need to have Microsoft Visual Studio C++ installed on your machine. However, the new version of Visual Studio, which I downloaded, does not have msdev.exe and instead uses vcbuild.exe, which has a completely different api and fails to compile the .dsp files that come with these modules. </p> <p>So I tried to find a script that would upgrade the dsp to work with vcbuild.exe...and it turns out vcbuild.exe can do that, but of course that didn't pan out. </p> <p>Another thing I tried was to find a make script for Windows (nmake2make). But there was no make file in the module's root folder.</p> <p>I tried also downloading Cygwin and MinGW in hopes of finding a build script that would work as simply as in *nix operating systems, but to no avail. </p> <p>How else do I use install PHP extensions on a Windows machine? Can anyone help me out of this predicament?</p>
[ { "answer_id": 250806, "author": "Robert K", "author_id": 24950, "author_profile": "https://Stackoverflow.com/users/24950", "pm_score": 2, "selected": false, "text": "C:\\xampp\\php\\ext ; Dynamic Extensions ; extension=my_lib.dll" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32816/" ]
250,774
<p>I want to make some passages of a standard tooltip bold in a WinForms application. Is this possible?</p> <p>If not, is there a (free) tooltip component that allows me to style them (preferably also border and background)?</p> <p>Thanks!</p>
[ { "answer_id": 20812702, "author": "user3141530", "author_id": 3141530, "author_profile": "https://Stackoverflow.com/users/3141530", "pm_score": -1, "selected": false, "text": "_toolTip.SetToolTip(button, String.Format(\"<font face=\\\"Microsoft Yahei\\\" color=\\\"blue\\\">{0}</font>\", Tooltip Text));\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
250,779
<p>I was taught that a regression test was a small (only enough to prove you didn't break anything with the introduction of a change or new modules) sample of the overall tests. However, <a href="http://www.iceincusa.com/16csp/content/16_smoke/smkrgt.htm" rel="noreferrer">this article</a> by Ron Morrison and Grady Booch makes me think differently:</p> <blockquote> <p>The desired strategy would be to bring each unit in one at a time, perform an extensive regression test, correct any defects and then proceed to the next unit.</p> </blockquote> <p>The same document also says:</p> <blockquote> <p>As soon as a small number of units are added, a test version is generated and "smoke tested," wherein a small number of tests are run to gain confidence that the integrated product will function as expected. The intent is neither to thoroughly test the new unit(s) nor to completely regression test the overall system.</p> </blockquote> <p>When describing smoke testing, the authors say this:</p> <blockquote> <p>It is also important that the Smoke Test perform a quick check of the entire system, not just the new component(s).</p> </blockquote> <p>I've never seen "extensive" and "regression test" used together nor a regression test described as "completely regression test the overall system". Regression tests are supposed to be as light and quick as possible. And the definition of smoke test is what I learned a regression test was.</p> <p>Did I misunderstand what I was taught? Was I taught incorrectly? Or are there multiple interpretations of "regression test"?</p>
[ { "answer_id": 250783, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 4, "selected": true, "text": "Foo Bar" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
250,789
<p>I have a CSV data file with rows that may have lots of columns 500+ and some with a lot less. I need to transpose it so that each row becomes a column in the output file. The problem is that the rows in the original file may not all have the same number of columns so when I try the transpose method of array I get:</p> <blockquote> <p>`transpose': element size differs (12 should be 5) (IndexError)</p> </blockquote> <p>Is there an alternative to transpose that works with uneven array length?</p>
[ { "answer_id": 250926, "author": "bltxd", "author_id": 11892, "author_profile": "https://Stackoverflow.com/users/11892", "pm_score": 4, "selected": true, "text": "a = [[1, 2, 3], [3, 4]]\n\n# This would throw the error you're talking about\n# a.transpose\n\n# Largest row\nsize = a.max { |r1, r2| r1.size <=> r2.size }.size\n\n# Enlarge matrix inserting nils as needed\na.each { |r| r[size - 1] ||= nil }\n\n# So now a == [[1, 2, 3], [3, 4, nil]]\naa = a.transpose\n\n# aa == [[1, 3], [2, 4], [3, nil]]\n" }, { "answer_id": 4526254, "author": "Vlad Alive", "author_id": 345182, "author_profile": "https://Stackoverflow.com/users/345182", "pm_score": 2, "selected": false, "text": "# Intitial CSV table data\ncsv_data = [ [1,2,3,4,5], [10,20,30,40], [100,200] ]\n\n# Finding max length of rows\nrow_length = csv_data.map(&:length).max\n\n# Inserting nil to the end of each row\ncsv_data.map do |row|\n (row_length - row.length).times { row.insert(-1, nil) }\nend\n\n# Let's check\ncsv_data\n# => [[1, 2, 3, 4, 5], [10, 20, 30, 40, nil], [100, 200, nil, nil, nil]]\n\n# Transposing...\ntransposed_csv_data = csv_data.transpose\n\n# Hooray!\n# => [[1, 10, 100], [2, 20, 200], [3, 30, nil], [4, 40, nil], [5, nil, nil]]\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6805/" ]
250,790
<p>So I'm creating some HTML using javascript based on where the user clicks on the page. On page load the script replaces an empty div with a ul and some data. The user clicks on that data to receive more and so on. Now when the user navigates off the page and then hits the back button to go back to the page, IE displays a blank page with the replaced divs, in all other browsers, FF, Opera, Safari, the page either reloads to the initial ul or goes back to the last state with the dynamic data in it.</p> <p>Anyone have an idea as to what might be happening here? Any help is appreciated.</p>
[ { "answer_id": 250926, "author": "bltxd", "author_id": 11892, "author_profile": "https://Stackoverflow.com/users/11892", "pm_score": 4, "selected": true, "text": "a = [[1, 2, 3], [3, 4]]\n\n# This would throw the error you're talking about\n# a.transpose\n\n# Largest row\nsize = a.max { |r1, r2| r1.size <=> r2.size }.size\n\n# Enlarge matrix inserting nils as needed\na.each { |r| r[size - 1] ||= nil }\n\n# So now a == [[1, 2, 3], [3, 4, nil]]\naa = a.transpose\n\n# aa == [[1, 3], [2, 4], [3, nil]]\n" }, { "answer_id": 4526254, "author": "Vlad Alive", "author_id": 345182, "author_profile": "https://Stackoverflow.com/users/345182", "pm_score": 2, "selected": false, "text": "# Intitial CSV table data\ncsv_data = [ [1,2,3,4,5], [10,20,30,40], [100,200] ]\n\n# Finding max length of rows\nrow_length = csv_data.map(&:length).max\n\n# Inserting nil to the end of each row\ncsv_data.map do |row|\n (row_length - row.length).times { row.insert(-1, nil) }\nend\n\n# Let's check\ncsv_data\n# => [[1, 2, 3, 4, 5], [10, 20, 30, 40, nil], [100, 200, nil, nil, nil]]\n\n# Transposing...\ntransposed_csv_data = csv_data.transpose\n\n# Hooray!\n# => [[1, 10, 100], [2, 20, 200], [3, 30, nil], [4, 40, nil], [5, nil, nil]]\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
250,792
<p>We're looking for a way to log any call to stored procedures in Oracle, and see what parameter values were used for the call.</p> <p>We're using Oracle 10.2.0.1</p> <p>We can log SQL statements and see the bound variables, but when we track stored procedures we see bind variables B1, B2, etc. but no values.</p> <p>We'd like to see the same kind of information we've seen in MS SQL Server Profiler.</p> <p>Thanks for any help</p>
[ { "answer_id": 251665, "author": "Clyde", "author_id": 945, "author_profile": "https://Stackoverflow.com/users/945", "pm_score": 0, "selected": false, "text": "Begin dbo.UPKG_PACKAGENAME.PROC(:v0, :v1, :v2 ...); End;\n/\nBegin dbo.UPKG_PACKAGENAME.PROC2(:v0, :v1, :v2 ...); End;\n/\n...\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/945/" ]
250,794
<p>I realize this would violate convention, but I'm curious to know if you can do this through configuration.</p> <p><strong>Edit: I understand why I wouldn't want to do this. BUT, I do want to understand the internals of this time of project.</strong></p>
[ { "answer_id": 250825, "author": "Larsenal", "author_id": 337, "author_profile": "https://Stackoverflow.com/users/337", "pm_score": 1, "selected": false, "text": "internal const string CodeDirectoryName = \"App_Code\";\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
250,801
<p>Hi does anybody know how to initialize two list at the same time with ajax?</p> <p>This is my code</p> <pre><code>&lt;html&gt; &lt;body onload="iniciaListas()"&gt; &lt;script type="text/javascript"&gt; var xmlHttp function iniciaListas() { muestraListaPaises(); muestraListaProfesiones(); } function muestraListaProfesiones() { //Se inicializa el objeto ajax para manipular los eventos asincronos al servidor xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } //Se obtine el id de la lista var obCon = document.getElementById("ocupacion"); //Por medio del metodo GET se llama nuestra pagina PHP xmlHttp.open("GET", "../Listas/listaProfesiones.php"); //On ready funcion es la funcion que se da cuenta cuando la pagina php acaba de hacer su proceso xmlHttp.onreadystatechange = function() { //el estado 4 indica que esta listo para procesar la instruccion if (xmlHttp.readyState == 4 &amp;&amp; xmlHttp.status == 200) { //despues que nuestro objeto ajax proceso la pagina php recupera un xml generado obXML = xmlHttp.responseXML; //despues obtine los datos contenidos en las siguites etiquetas obCod = obXML.getElementsByTagName("ID"); obDes = obXML.getElementsByTagName("NOMPROFESION"); //esta funcion devuelve en su la longitud de todos los registros obCon.length=obCod.length; //cilclo de llenado para las listas for (var i=0; i&lt;obCod.length;i++) { obCon.options[i].value=obCod[i].firstChild.nodeValue; obCon.options[i].text=obDes[i].firstChild.nodeValue; } } } //este objeto envia un nulll debido a que el metodo utilizado es get xmlHttp.send(null); } function muestraListaPaises() { //Se inicializa el objeto ajax para manipular los eventos asincronos al servidor xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } //Se obtine el id de la lista var obCon = document.getElementById("pais"); //Por medio del metodo GET se llama nuestra pagina PHP xmlHttp.open("GET", "../Listas/listaPaises.php"); //On ready funcion es la funcion que se da cuenta cuando la pagina php acaba de hacer su proceso xmlHttp.onreadystatechange = function() { //el estado 4 indica que esta listo para procesar la instruccion if (xmlHttp.readyState == 4 &amp;&amp; xmlHttp.status == 200) { //despues que nuestro objeto ajax proceso la pagina php recupera un xml generado obXML = xmlHttp.responseXML; //despues obtine los datos contenidos en las siguites etiquetas obCod = obXML.getElementsByTagName("ID"); obDes = obXML.getElementsByTagName("NOMPAIS"); //esta funcion devuelve en su la longitud de todos los registros obCon.length=obCod.length; //cilclo de llenado para las listas for (var i=0; i&lt;obCod.length;i++) { obCon.options[i].value=obCod[i].firstChild.nodeValue; obCon.options[i].text=obDes[i].firstChild.nodeValue; } } } //este objeto envia un nulll debido a que el metodo utilizado es get xmlHttp.send(null); } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } &lt;/script&gt; &lt;html&gt; &lt;body onload="iniciaListas()"&gt; &lt;script type="text/javascript" src="lists.js"&gt; &lt;/script&gt; &lt;b&gt;Country&lt;/b&gt;&lt;br&gt; &lt;select name="pais" id="pais" &gt;&lt;/select&gt; &lt;b&gt;Ocupation&lt;/b&gt;&lt;br&gt; &lt;select name="pais" id="pais" &gt;&lt;/select&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 250820, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 2, "selected": false, "text": "//Se obtine el id de la lista\nvar obCon = document.getElementById(\"pais\");\nvar obOcupation = document.getElementById(\"ocupation\");\n\n...\n\nfor (var i=0; i<obCod.length;i++) {\n obCon.options[i].value=obCod[i].firstChild.nodeValue;\n obCon.options[i].text=obDes[i].firstChild.nodeValue;\n obOcupation.options[i].value=obCod[i].firstChild.nodeValue;\n obOcupation.options[i].text=obDes[i].firstChild.nodeValue;\n}\n <html>\n<body onload=\"iniciaListas()\">\n<script type=\"text/javascript\" src=\"lists.js\"> </script>\n<b>Country</b><br>\n<select name=\"pais\" id=\"pais\" ></select>\n\n<b>Ocupation</b><br>\n<select name=\"ocupation-pais\" id=\"ocupation\" ></select>\n</body>\n\n</html>\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
250,818
<p>How do I find a stored procedure in a Sybase database given a text string that appears somewhere in the proc? I want to see if any other proc in the db has similar logic to the one I'm looking at, and I think I have a pretty unique search string (literal)</p> <p>Edit:</p> <p>I'm using Sybase version 11.2</p>
[ { "answer_id": 250862, "author": "Graeme Perrow", "author_id": 1821, "author_profile": "https://Stackoverflow.com/users/1821", "pm_score": 3, "selected": false, "text": "select * from SYS.SYSPROCEDURE where proc_defn like '%whatever%'\n select * from syscomments where texttype = 0 and text like '%whatever%'\n" }, { "answer_id": 268773, "author": "AdamH", "author_id": 21081, "author_profile": "https://Stackoverflow.com/users/21081", "pm_score": 4, "selected": false, "text": "select object_name(id),* from syscomments \n where texttype = 0 and text like '%whatever%'\n select distinct object_name(id) from syscomments \n where texttype = 0 and text like '%whatever%'\n" }, { "answer_id": 3237687, "author": "Tom", "author_id": 390487, "author_profile": "https://Stackoverflow.com/users/390487", "pm_score": 3, "selected": false, "text": "select * from sysobjects where \n id in ( select distinct (id) from syscomments where text like '%SearchTerm%')\n and xtype = 'P'\n" }, { "answer_id": 3464875, "author": "Nishad", "author_id": 418003, "author_profile": "https://Stackoverflow.com/users/418003", "pm_score": 2, "selected": false, "text": "select distinct object_name(syscomments.id) 'SearchText', syscomments.id from syscomments ,sysobjects \n where texttype = 0 and text like '%SearchText%' and syscomments.id=sysobjects.id and sysobjects.type='P'\n" }, { "answer_id": 8668228, "author": "B0rG", "author_id": 122093, "author_profile": "https://Stackoverflow.com/users/122093", "pm_score": 3, "selected": false, "text": "declare @text varchar(100)\nselect @text = \"%whatever%\"\n\nselect distinct o.name object\nfrom sysobjects o,\n syscomments c\nwhere o.id=c.id\nand o.type='P'\nand (c.text like @text\nor exists(\n select 1 from syscomments c2 \n where c.id=c2.id \n and c.colid+1=c2.colid \n and right(c.text,100)+ substring(c2.text, 1, 100) like @text \n )\n)\norder by 1\n" }, { "answer_id": 50725116, "author": "Fadi Hatem", "author_id": 2351954, "author_profile": "https://Stackoverflow.com/users/2351954", "pm_score": 0, "selected": false, "text": "select distinct object_name(sc1.id)\nfrom syscomments sc1\nleft join syscomments sc2\non (sc2.id = sc1.id and \nsc2.number = sc1.number and\nsc2.colid2 = sc1.colid2 + ((sc1.colid + 1) / 32768) and\nsc2.colid = (sc1.colid + 1) % 32768)\nwhere\nsc1.texttype = 0 and\nsc2.texttype = 0 and\nlower(sc1.text + sc2.text) like lower('%' || @textSearched || '%')\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5472/" ]
250,840
<p>The TextWrapping property of the TextBox has three possible values:</p> <ul> <li>Wrap</li> <li>NoWrap</li> <li>WrapWithOverflow</li> </ul> <p>I would like to bind to the IsChecked property of a MenuItem. If the MenuItem is checked, I want to set the TextWrapping property of a TextBox to Wrap. If the MenuItem is not checked, I want to set the TextWrapping property of the TextBox to NoWrap.</p> <p>To sum up, I am trying to bind a control that has two states to two values of an enumeration that has more than two values.</p> <p><strong>[edit]</strong> I would like to accomplish this in XAML, if possible.</p> <p><strong>[edit]</strong> I figured out how to do this using an IValueConverter. Perhaps there is a better way to do this? Here is what I did:</p> <hr> <p>In Window.Resources, I declared a reference to my ValueConverter.</p> <pre><code>&lt;local:Boolean2TextWrapping x:Key="Boolean2TextWrapping" /&gt; </code></pre> <p>In my TextBox, I created the binding to a MenuItem and included the Converter in the binding statement.</p> <pre><code>TextWrapping="{Binding ElementName=MenuItemWordWrap, Path=IsChecked, Converter={StaticResource Boolean2TextWrapping}}" </code></pre> <p>and the ValueConverter looks like this:</p> <pre><code>public class Boolean2TextWrapping : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo cultureInfo) { if (((bool)value) == false) { return TextWrapping.NoWrap; } return TextWrapping.Wrap; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } </code></pre>
[ { "answer_id": 252284, "author": "Todd White", "author_id": 30833, "author_profile": "https://Stackoverflow.com/users/30833", "pm_score": 4, "selected": true, "text": "<StackPanel>\n <CheckBox x:Name=\"WordWrap\">Word Wrap</CheckBox>\n <TextBlock Width=\"50\">\n Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin lacinia nibh non augue. Pellentesque pretium neque et neque auctor adipiscing.\n\n <TextBlock.Style>\n <Style TargetType=\"{x:Type TextBlock}\">\n <Style.Triggers>\n <DataTrigger Binding=\"{Binding IsChecked, ElementName=WordWrap}\" Value=\"True\">\n <Setter Property=\"TextWrapping\" Value=\"Wrap\" />\n </DataTrigger>\n </Style.Triggers>\n </Style>\n </TextBlock.Style>\n </TextBlock>\n</StackPanel>\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12919/" ]
250,845
<blockquote> <p>Clarification: this is not about <em>user agent</em> calls to pages, but Classic ASP calling ASP.NET!</p> </blockquote> <p>I have applications that are midway through a transition from Classic ASP to ASP.NET. There are a half million lines of code, so a complete rewrite of everything at once was simply not plausible, or frankly prudent considering that the vast majority of Classic ASP pages work just fine. We translate pages and functionality as they come up for revision <em>anyway</em>, not just because it is "cool".</p> <p>Now that about half the pages have been converted we have moved some of the key functionality over to ASP.NET. Instead of keeping the legacy versions of this functionality (which means two places to maintain instead of one) I have been moving towards using SOAP to expose this functionality.</p> <p>Well... not really. Instead, we have been using what I used to call "Poor Man's SOAP", although today it is trendy to call it REST. I have been using ServerXMLHTTP to contact the destination page, bundling up a ball of XML and POSTing it over to the ASP.NET side. For the result I have been bundling up some XML and using XPATH to tear it down into variables.</p> <p>All of this works surprisingly well. However, I have been contemplating the built in ASP.NET SOAP features, which would seem to remove the need to custom write landing pages for my cross platform calls... but when I look at consuming SOAP from Classic ASP most suggest using the seemingly depreciated Soap Toolkit. </p> <p>The question is; do any of you have experience with this kind of setup and if so are there any better ways to do it than custom REST pages or Soap Toolkit? I think being able to expose more of the ASP.NET functionality quicker would help with the migration, but I don't want to get myself mired in legacy technology like Soap Toolkit unnecessarily.</p>
[ { "answer_id": 1749591, "author": "wwilkins", "author_id": 4098, "author_profile": "https://Stackoverflow.com/users/4098", "pm_score": 1, "selected": false, "text": "Set xmlhttp = CreateObject(\"MSXML2.ServerXMLHTTP\") \nxmlhttp.open \"POST\", soapServer, False\nxmlhttp.setRequestHeader \"Content-Type\", \"text/xml; charset=utf-8\"\nxmlhttp.setRequestHeader \"SOAPAction\", char(34) & \"WebPlatform.WebServices/ISessionTokenServiceV1/CreateSessionToken\" & char(34)\n\nxmlhttp.send soapMessage\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28006/" ]
250,846
<p>I am loading some data from an XML document, modifying it, and writing back out to XML. The reading is done using a SAX parser library and the writing is done with a piece of custom code. Sometimes, the file is modified externally, and extra elements are added (such as references to stylesheets). Rather than losing these extra elements when I load and save the file, I would like to pass through any unknown tags so that they appear </p> <p>When unknown elements are separate from interpreted elements, it should be straightforward to save unknown elements and attributes as strings and output these afterwards, but when they are interspersed and nested inside interpreted elements, it becomes less obvious. </p> <p>Can anybody suggest a succinct way to do this? Would it be simpler to switch to a DOM parser? Performance is not an issue.</p> <p><em>NB.</em> I am working in C++ with the Gnome Glib::Markup::Parser, but would prefer language/library agnostic answers.</p>
[ { "answer_id": 251295, "author": "ChuckB", "author_id": 28605, "author_profile": "https://Stackoverflow.com/users/28605", "pm_score": 1, "selected": false, "text": "startElement() endElement()" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32817/" ]
250,849
<p>Similar to the one here on StackOverFlow, I would be needing to implement a way for people to vote up and vote down comments in a forum like site.</p> <p>However instead of having a generic overall score, we will display the total amount of "thumbs up" and "thumbs down". The overall score will be needed for filtering purposes, such as "sort by highest rated", "show only ratings with + 3"</p> <p>What is the best implementation strategy?</p> <p>As a user suggested, I would also be storing the information who casted the vote</p>
[ { "answer_id": 250861, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 3, "selected": true, "text": "SUM-WHERE" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32372/" ]
250,867
<p>Assuming a table of tags like the stackoverflow question tags:</p> <blockquote> <p>TagID (bigint), QuestionID (bigint), Tag (varchar)</p> </blockquote> <p>What is the most efficient way to get the 25 most used tags using LINQ? In SQL, a simple GROUP BY will do:</p> <pre><code>SELECT Tag, COUNT(Tag) FROM Tags GROUP BY Tag </code></pre> <p>I've written some LINQ that works:</p> <pre><code>var groups = from t in DataContext.Tags group t by t.Tag into g select new { Tag = g.Key, Frequency = g.Count() }; return groups.OrderByDescending(g =&gt; g.Frequency).Take(25); </code></pre> <p>Like, really? Isn't this mega-verbose? The sad thing is that I'm doing this to save a massive number of queries, as my Tag objects already contain a Frequency property that would otherwise need to check back with the database for every Tag if I actually used the property.</p> <p>So I then parse these anonymous types <em>back</em> into Tag objects:</p> <pre><code>groups.OrderByDescending(g =&gt; g.Frequency).Take(25).ToList().ForEach(t =&gt; tags.Add(new Tag() { Tag = t.Tag, Frequency = t.Frequency })); </code></pre> <p>I'm a LINQ newbie, and this doesn't seem right. Please show me how it's really done.</p>
[ { "answer_id": 250910, "author": "GalacticCowboy", "author_id": 29638, "author_profile": "https://Stackoverflow.com/users/29638", "pm_score": 5, "selected": false, "text": "var groups = from t in DataContext.Tags\n group t by t.Tag into g\n select new Tag() { Tag = g.Key, Frequency = g.Count() };\n\nreturn groups.OrderByDescending(g => g.Frequency).Take(25);\n" }, { "answer_id": 251226, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 4, "selected": false, "text": "List<Tag> result = \n db.Tags\n .GroupBy(t => t.Tag)\n .Select(g => new {Tag = g.Key, Frequency = g.Count()})\n .OrderByDescending(t => t.Frequency)\n .Take(25)\n .ToList()\n .Select(t => new Tag(){Tag = t.Tag, Frequency = t.Frequency})\n .ToList();\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
250,868
<p>I've heard that there are some things one cannot do as a computer programmer, but I don't know what they are. One thing that occurred to me recently was: wouldn't it be nice to have a class that could make a copy of the source of the program it runs, modify that program and add a method to the class that it is, and then run the copy of the program and terminate itself. Is it possible for code to write code?</p>
[ { "answer_id": 250893, "author": "dlamblin", "author_id": 459, "author_profile": "https://Stackoverflow.com/users/459", "pm_score": 5, "selected": true, "text": "#include<stdio.h>\n\nmain()\n{\n char *a = \"main(){char *a = %c%s%c; int b = '%c'; printf(a,b,a,b,b);}\";\n int b = '\"';\n printf(a,b,a,b,b);\n}\n" }, { "answer_id": 250894, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 1, "selected": false, "text": "$data" }, { "answer_id": 263666, "author": "fmsf", "author_id": 26004, "author_profile": "https://Stackoverflow.com/users/26004", "pm_score": 1, "selected": false, "text": "(eval '(or true false))\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29182/" ]
250,874
<p>How do implement the iterator pattern in <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="nofollow noreferrer">VB.NET</a>, which does not have the <code>yield</code> keyword?</p>
[ { "answer_id": 5712861, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 5, "selected": true, "text": "Private Iterator Function SomeNumbers() As IEnumerable\n ' Use multiple yield statements.\n Yield 3\n Yield 5\n Yield 8\nEnd Function\n" }, { "answer_id": 5856403, "author": "meenakshisundaram muthukrishna", "author_id": 734254, "author_profile": "https://Stackoverflow.com/users/734254", "pm_score": -1, "selected": false, "text": "Public Shared Function setofNumbers() As Integer()\n\n Dim counter As Integer = 0\n Dim results As New List(Of Integer)\n Dim result As Integer = 1\n While counter < 5\n result = result * 2\n results.Add(result)\n counter += 1\n End While\n Return results.ToArray()\nEnd Function\n\nPrivate Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load\n For Each i As Integer In setofNumbers()\n MessageBox.Show(i)\n Next\nEnd Sub\n private void Form1_Load(object sender, EventArgs e)\n{\n foreach (int i in setofNumbers())\n {\n MessageBox.Show(i.ToString());\n }\n}\n\npublic static IEnumerable<int> setofNumbers()\n{\n int counter=0;\n //List<int> results = new List<int>();\n int result=1;\n while (counter < 5)\n {\n result = result * 2;\n counter += 1;\n yield return result;\n }\n}\n" }, { "answer_id": 9181839, "author": "Richard Collette", "author_id": 107683, "author_profile": "https://Stackoverflow.com/users/107683", "pm_score": 0, "selected": false, "text": " Private Sub AddOrRemoveUsersFromRoles(procName As String,\n applicationId As Integer,\n userNames As String(),\n rolenames As String())\n Dim sqldb As SqlDatabase = CType(db, SqlDatabase)\n Dim command As DbCommand = sqldb.GetStoredProcCommand(procName)\n Dim record As New SqlDataRecord({New SqlMetaData(\"value\", SqlDbType.VarChar,200)})\n Dim setRecord As Func(Of String, SqlDataRecord) =\n Function(value As String)\n record.SetString(0, value)\n Return record\n End Function\n Dim userNameRecords As IEnumerable(Of SqlDataRecord) = userNames.Select(setRecord)\n Dim roleNameRecords As IEnumerable(Of SqlDataRecord) = rolenames.Select(setRecord)\n With sqldb\n .AddInParameter(command, \"userNames\", SqlDbType.Structured, userNameRecords)\n .AddInParameter(command, \"roleNames\", SqlDbType.Structured, roleNameRecords)\n .AddInParameter(command, \"applicationId\", DbType.Int32, applicationId)\n .AddInParameter(command, \"currentUserName\", DbType.String, GetUpdatingUserName)\n .ExecuteNonQuery(command)\n End With\nEnd Sub\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31766/" ]
250,890
<p>I have a <code>QDirModel</code> whose current directory is set. Then I have a <code>QListView</code> which is supposed to show the files in that directory. This works fine.</p> <p>Now I want to limit the files shown, so it only shows <em>png</em> files (the filename ends with .png). The problem is that using a <code>QSortFilterProxyModel</code> and setting the filter regexp will try to match every parent of the files as well. According to the documentation:</p> <blockquote> <p>For hierarchical models, the filter is applied recursively to all children. If a parent item doesn't match the filter, none of its children will be shown.</p> </blockquote> <p>So, how do I get the <code>QSortFilterProxyModel</code> to only filter the files in the directory, and not the directories it resides in?</p>
[ { "answer_id": 253949, "author": "Caleb Huitt - cjhuitt", "author_id": 9876, "author_profile": "https://Stackoverflow.com/users/9876", "pm_score": 3, "selected": false, "text": "filterAcceptsRow" }, { "answer_id": 4106006, "author": "RoLi", "author_id": 498317, "author_profile": "https://Stackoverflow.com/users/498317", "pm_score": 2, "selected": false, "text": "bool YourQSortFilterProxyModel::filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const\n{\n if (source_parent == qobject_cast<QStandardItemModel*>(sourceModel())->invisibleRootItem()->index())\n {\n // always accept children of rootitem, since we want to filter their children \n return true;\n }\n\n return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);\n}\n" }, { "answer_id": 10911768, "author": "azf", "author_id": 419472, "author_profile": "https://Stackoverflow.com/users/419472", "pm_score": 3, "selected": false, "text": "bool MySortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex & source_parent) const\n{\n // custom behaviour :\n if(filterRegExp().isEmpty()==false)\n {\n // get source-model index for current row\n QModelIndex source_index = sourceModel()->index(source_row, this->filterKeyColumn(), source_parent) ;\n if(source_index.isValid())\n {\n // if any of children matches the filter, then current index matches the filter as well\n int i, nb = sourceModel()->rowCount(source_index) ;\n for(i=0; i<nb; ++i)\n {\n if(filterAcceptsRow(i, source_index))\n {\n return true ;\n }\n }\n // check current index itself :\n QString key = sourceModel()->data(source_index, filterRole()).toString();\n return key.contains(filterRegExp()) ;\n }\n }\n // parent call for initial behaviour\n return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent) ;\n}\n" }, { "answer_id": 55050729, "author": "Caleb Koch", "author_id": 3987765, "author_profile": "https://Stackoverflow.com/users/3987765", "pm_score": 3, "selected": false, "text": "QSortFilterProxyModel" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1585/" ]
250,901
<p>I was wondering what would be the best approach you guys would take to relocate an entire Eclipse workspace? Assuming it's either versioned and exported, what would you do? Import the file? Checkout the whole thing from the repo? Thanks much in advance!</p>
[ { "answer_id": 250908, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 0, "selected": false, "text": "Switch workspace File" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6992/" ]
250,911
<p>An application I am working on reads information from files to populate a database. Some of the characters in the files are non-English, for example accented French characters.</p> <p>The application is working fine in Windows but on our Solaris machine it is failing to recognise the special characters and is throwing an exception. For example when it encounters the accented e in "Gérer" it says :-</p> <pre> Encountered: "\u0161" (353), after : "\'G\u00c3\u00a9rer les mod\u00c3"</pre> <p>(an exception which is thrown from our application)</p> <p>I suspect that in order to stop this from happening I need to change the file.encoding property of the JVM. I tried to do this via System.setProperty() but it has not stopped the error from occurring.</p> <p>Are there any suggestions for what I could do? I was thinking about setting the basic locale of the solaris platform in /etc/default/init to be UTF-8. Does anyone think this might help?</p> <p>Any thoughts are much appreciated.</p>
[ { "answer_id": 250944, "author": "sakana", "author_id": 28921, "author_profile": "https://Stackoverflow.com/users/28921", "pm_score": 2, "selected": false, "text": "java -Dfile.encoding=UTF-8 ...\n" }, { "answer_id": 250947, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 0, "selected": false, "text": "java -Dfile.encoding=utf-8" }, { "answer_id": 251286, "author": "Alan Moore", "author_id": 20938, "author_profile": "https://Stackoverflow.com/users/20938", "pm_score": 2, "selected": false, "text": "native2ascii Gérer les modÚ\n native2ascii -encoding windows-1252 a.txt b.txt\n G\\u00c3\\u00a9rer les mod\\u00c3\\u0161\n native2ascii -reverse -encoding ISO-8859-1 b.txt c.txt\n Gérer les modÀ\\u0161\n" }, { "answer_id": 252146, "author": "Dov Wasserman", "author_id": 26010, "author_profile": "https://Stackoverflow.com/users/26010", "pm_score": 1, "selected": false, "text": "String.getBytes()" }, { "answer_id": 2895105, "author": "mohitsoni", "author_id": 154917, "author_profile": "https://Stackoverflow.com/users/154917", "pm_score": 0, "selected": false, "text": "BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(inputPath),\"UTF-8\"));\n PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputPath), \"UTF-8\")));\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22061/" ]
250,931
<p>I have some HTML that displays fine on FireFox3/Opera/Safari but not with IE7. The snippet is as follows:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt;&lt;/head&gt; &lt;body bgcolor="#AA5566" &gt; &lt;table width="100%"&gt; &lt;tr&gt; &lt;td height="37" valign="top"&gt;&lt;img style="float:right;" border="0" src="foo.png" width="37" height="37"/&gt;&lt;/td&gt; &lt;td width="600" rowspan="2" &gt; &lt;table width="600" height="800"&gt;&lt;tr&gt;&lt;td&gt;&lt;img src="bar.jpg" width="600" height="800"/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;/td&gt; &lt;td height="37" valign="top"&gt;&lt;img style="float:left;" border="0" src="foo.png" width="37" height="37"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;!-- This row doesnt fill the vertical space on IE7 //--&gt; &lt;tr&gt; &lt;td valign="top" bgcolor="#112233"&gt;&amp;nbsp;&lt;/td&gt; &lt;td valign="top" bgcolor="#112233"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; </code></pre> <p>The second row wont fill the vertical space created by the first rows middle column (notice the rowspan="2") correctly. Instead the first rows 1st and 3rd columns expand down even though I set their height to 37. The image below shows what happens in IE7 and Firefox3...</p> <p><img src="https://i.stack.imgur.com/DpxMK.png" alt="alt text"></p> <p>EDIT: added the HTML doc type to the code snippit. Added a screenshot.</p> <p>Any help appreciated, thanks :)</p>
[ { "answer_id": 251315, "author": "Eli", "author_id": 27580, "author_profile": "https://Stackoverflow.com/users/27580", "pm_score": 3, "selected": true, "text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head></head>\n <body bgcolor=\"#AA5566\" >\n <table width=\"100%\" border='1'>\n\n <tr>\n\n <td valign=\"top\">\n <table bgcolor=\"#112233\" height=\"37\" width='100%'><tr><td>asdf</td></tr></table><br />\n Other content\n </td>\n\n <td width=\"600\" rowspan=\"2\" >\n <table width=\"600\" height=\"800\"><tr><td>asdf</td></tr></table>\n </td>\n\n <td valign=\"top\">\n <table bgcolor=\"#112233\" height=\"37\" width='100%'><tr><td>asdf</td></tr></table><br />\n Other content\n </td>\n\n </tr>\n\n\n\n </table>\n </body>\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14260/" ]
250,932
<p>I have a hyper link like this :</p> <pre><code>&lt;A Href=My_Java_Servlet?User_Action=Admin_Download_Records&amp;User_Id=Admin onClick=\"Check_Password();\" target=_blank&gt;Download Records&lt;/A&gt; </code></pre> <p>When a user clicks on it, a password window will open, the user can try 3 times for the right password.</p> <p>The Javascript looks like this :</p> <pre><code>&lt;Script Language="JavaScript"&gt; function Check_Password() { var testV=1; var pass1=prompt('Password',''); while (testV&lt;3) { if (!pass1) history.go(-1); if (pass1=="password") { return true; } testV+=1; var pass1=prompt('Access Denied - Password Incorrect.',''); } return "false"; } &lt;/Script&gt; </code></pre> <p>If user enters the wrong password 3 times, it's supposed to not do anything, but it still opens a new window and displays the protected info, how to fix the javascript or my html hyper link so only the right password will open a new target window, a wrong password will make it do nothing ?</p>
[ { "answer_id": 250943, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 1, "selected": false, "text": "false \"false\"" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32834/" ]
250,937
<p>I have a very simple ASP.Net page that acts as a front end for a stored procedure. It just runs the procedure and shows the output using a gridview control: less than 40 lines of total code, including aspx markup. The stored procedure itself is very... volatile. It's used for a number of purposes and the output format changes regularly. </p> <p>The whole thing works great, because the gridview control doesn't really need to care what columns the stored procedure returns: it just shows them on the page, which is exactly what I want.</p> <p>However, the database this runs against has a number of datetime columns all over the place where the time portion isn't really important- it's always zeroed out. What I would like to be able to do is control the formatting of just the datetime columns in the gridview, without ever knowing precisely which columns those will be. Any time a column in the results has a datetime type, just apply a given format string that will trim off the time component.</p> <p>I know I could convert to a varchar at the database, but I'd really don't want to have to make developers care about formatting in the query and this belongs at the presentation level anyway. Any other ideas?</p> <hr> <p>Finally got this working in an acceptable (or at least improved) way using this code:</p> <pre><code>Protected Sub OnRowDatabound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then Dim d As DateTime For Each cell As TableCell In e.Row.Cells If Date.TryParse(cell.Text, d) AndAlso d.TimeOfDay.Ticks = 0 Then cell.Text = d.ToShortDateString() End If Next cell End If End Sub </code></pre>
[ { "answer_id": 250963, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 2, "selected": false, "text": "<asp:BoundField DataField=\"Whatever\" ... DataFormatString=\"{0:dd/MM/yyyy}\" HtmlEncode=\"False\"/ > \n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
250,940
<p>I have an SQLite table that contains a BLOB I need to do a size/length check on. How do I do that?</p> <p>According to documentation <code>length(blob)</code> only works on texts and will stop counting after the first NULL. My tests confirmed this. I'm using SQLite 3.4.2.</p>
[ { "answer_id": 251134, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 7, "selected": true, "text": "length(hex(glob))/2 length(blob_column)" }, { "answer_id": 3780193, "author": "Chris", "author_id": 456378, "author_profile": "https://Stackoverflow.com/users/456378", "pm_score": 4, "selected": false, "text": "length(blob)" }, { "answer_id": 16469452, "author": "ubzack", "author_id": 632879, "author_profile": "https://Stackoverflow.com/users/632879", "pm_score": 2, "selected": false, "text": "select myblob mytable select length(myblob) from mytable where rowid=3;\n" }, { "answer_id": 21930147, "author": "user3336503", "author_id": 3336503, "author_profile": "https://Stackoverflow.com/users/3336503", "pm_score": 2, "selected": false, "text": "# sqlite --version\n3.7.13 2012-06-11 02:05:22 f5b5a13f7394dc143aa136f1d4faba6839eaa6dc\n\n# sqlite xxx.db \"SELECT docid, LENGTH(doccontent), LENGTH(HEX(doccontent))/2 AS b FROM cr_doc LIMIT 10;\"\n1|6|77824\n2|5|176251\n3|5|176251\n4|6|39936\n5|6|43520\n6|494|101447\n7|6|41472\n8|6|61440\n9|6|41984\n10|6|41472\n" }, { "answer_id": 31896266, "author": "Remember Monica", "author_id": 1303846, "author_profile": "https://Stackoverflow.com/users/1303846", "pm_score": 3, "selected": false, "text": "insert into table values ('xxxx'); // string insert\ninsert into table values(cast('xxxx' as blob)); // blob insert\n select length(string-value-from-blob-column); // treast blob column as string\nselect length(cast(blob-column as blob)); // correctly returns blob length\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2815/" ]
250,969
<p>I believe that quantifying the productivity increase (extra working hours) is the most effective way to do this.</p> <p>My case in point: I have a fast machine at home and a slow one at work. My estimate is that I would gain about 30 minutes a day of extra productivity at work if I had my home machine at work. This productivity would come from less waiting to do all the tasks that I do. (An extra 30 minutes a day is about 3 weeks a year.)</p> <p>Problem: I need to measure this.</p> <p>Is there a software utility that can monitor and scientifically quantify time taken by tasks on a machine?</p>
[ { "answer_id": 251047, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 0, "selected": false, "text": "time" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
250,970
<p>The object I’m working on is instantiated in JavaScript, but used in VBScript. In one code path, the variable <code>M.DOM.IPt</code> is defined and has a value, in the other however it is not. I need to detect if it has been defined or not. I checked that <code>M.DOM</code> is defined and accessable in both code paths. Every test I have tried simply results in this error:</p> <blockquote> <p>Error: Object doesn't support this property or method</p> </blockquote> <p>I have tried:</p> <ul> <li><code>IsEmpty(M.DOM.IPt)</code></li> <li><code>M.DOM.IPt is Nothing</code></li> <li><code>isNull(M.DOM.IPt)</code></li> </ul> <p>Is there any way to detect the variable isn’t defined and avoid the error?</p> <p>Note: I can put <code>On Error Resume Next</code> in and it will simply ignore the error, but I actually need to detect it and conditionally do something about it.</p>
[ { "answer_id": 251107, "author": "Arvo", "author_id": 35777, "author_profile": "https://Stackoverflow.com/users/35777", "pm_score": 1, "selected": false, "text": "On Error Resume Next\nErr.Clear\nMyVariable=M.DOM.Ipt\nIf Err.Number<> 0 Then\n 'error occured - Ipt not defined\n 'do your processing here\nElse\n 'no error - Ipt is defined\n 'do your processing here\nEnd If\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/80/" ]
250,973
<p>I wanted to write a Visual Studio Macro or something similar which can fetch function name and insert into preset location in the error report part. It's clearer if you look at the example</p> <pre><code>Class SampleClass { public void FunctionA() { try { //Do some work here } catch (Exception ex) { Logger.WriteLine(LogLevelEnum.Error, "SampleClass", "FunctionA Failed"); Logger.WriteLine(LogLevelEnum.Error, "FunctionA", ex.ToString()); } finally { } } } </code></pre> <p>So, I followed the similar pattern of most of the critical functions of my common library. I would like to be able to insert "FunctionA" into the logging section during pre-built so that I don't have to remember to type in the right name or forgetting to rename it after copy and paste. Either that can be invoke manually from the toolbar or via shortcut key.</p> <p>So, where should I start?</p> <p>NOTE: I'm considered intermediate in .Net, been writting in C# and VB for more than 3 years, but I'm fresh on Macro, don't mind to learn though. Don't worry about the code itself and the exception, this is just an example.</p> <p>EDIT: Thanks Ovidiu Pacurar and cfeduke. What I wanted here was a one off way to change-and-forget. PostSharp will incur overhead on every one of those function, even when exception is not thrown. Digging from the stacktrace is feasible, but at some point I would also like to just log "FunctionA Failed" without spending too much processing in getting the stacktrace. Further more, if the library is obfuscated, the stacktrace would be cryptic.</p> <p>Actually there was another need for this feature, which I forgot to mention earlier. When the library is ready to be delivered, I would want to change all the function name into function code, "FunctionA" might be "0001", by referring to a table, so as to solve the "obfuscated" log problem.</p>
[ { "answer_id": 251042, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 1, "selected": false, "text": "__FILE__ __LINE__ public class SimplestTraceAttribute : OnMethodBoundaryAspect\n{\n public override void OnEntry( MethodExecutionEventArgs eventArgs)\n {\n Trace.TraceInformation(\"Entering {0}.\", eventArgs.Method);\n Trace.Indent();\n }\n public override void OnExit( MethodExecutionEventArgs eventArgs)\n {\n Trace.Unindent();\n Trace.TraceInformation(\"Leaving {0}.\", eventArgs.Method);\n }\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20007/" ]
250,980
<p>How can one open a PNG formatted image file with VB6? Ideally, I (that is my customer) would like to have the PNG file open and placed into seperate R(ed), G(reen) and B(lue) arrays.</p> <p>VB6 is not my tool of choice (for lack of knowledge) and I be thrilled if some one could point me in the right direction for a VB6 solution.</p>
[ { "answer_id": 251042, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 1, "selected": false, "text": "__FILE__ __LINE__ public class SimplestTraceAttribute : OnMethodBoundaryAspect\n{\n public override void OnEntry( MethodExecutionEventArgs eventArgs)\n {\n Trace.TraceInformation(\"Entering {0}.\", eventArgs.Method);\n Trace.Indent();\n }\n public override void OnExit( MethodExecutionEventArgs eventArgs)\n {\n Trace.Unindent();\n Trace.TraceInformation(\"Leaving {0}.\", eventArgs.Method);\n }\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/250980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32836/" ]
251,030
<p>In <a href="https://stackoverflow.com/questions/226206/alternating-item-style">this question</a>, I was given a really cool answer to alternating an image and its description between left and right, respectively. Now I want to apply styling to both, e.g. padding-top, padding-bottom etc. How do I apply a style to both the RowStyle and AlternatingRowStyle in this scenario.</p> <pre><code>&lt;AlternatingRowStyle CssClass="ProductAltItemStyle" /&gt; &lt;RowStyle CssClass="ProductItemStyle" /&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;div class="Image"&gt;&lt;asp:Image runat="server" ID="productImage" ImageUrl='&lt;%# Eval("imageUrl") %&gt;' /&gt;&lt;/div&gt; &lt;div class="Description"&gt;&lt;asp:Label runat="server" ID="lblProductDesc" Width="100%" Text='&lt;%# Eval("productDesc") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/div&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre>
[ { "answer_id": 251037, "author": "changelog", "author_id": 5646, "author_profile": "https://Stackoverflow.com/users/5646", "pm_score": 5, "selected": false, "text": ".ProductAltItemStyle, .ProductItemStyle {\n // CSS Rules that apply to both go here\n}" }, { "answer_id": 251160, "author": "Herb Caudill", "author_id": 239663, "author_profile": "https://Stackoverflow.com/users/239663", "pm_score": 3, "selected": true, "text": "<AlternatingRowStyle CssClass=\"ProductAltItemStyle ProductCommonStyle\" /> \n<RowStyle CssClass=\"ProductItemStyle ProductCommonStyle\" />\n table.GridViewStyle tr td\n{\n padding:3px 5px;\n border:1px solid gray;\n}\n\ntr.ProductAltItemStyle td\n{\n background:white;\n}\n\ntr.ProductItemSTyle td\n{\n background:silver;\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
251,033
<p>How can I convert a varchar field of the form YYYYMMDD to a datetime in T-SQL?</p> <p>Thank you.</p>
[ { "answer_id": 251045, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 5, "selected": true, "text": "select convert(datetime, '20081030')\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
251,035
<p>I have a simple app which is writing to an xml file on every button click. Once this is done, I read the Xml file soon after (as in, a couple of lines below with no methods to be stepped in to in between).</p> <p>When the app runs for the first time, the xml file is written to/read from fine, but if I press the button again I get a "File is in use by another process". I am doing the whole flush, close, dispose thing with my streams and intend on using ProcessMon to check what process is holding the file.</p> <p>Programatically, what is the best strategy to avoid this problem?</p> <p>Thanks</p>
[ { "answer_id": 251174, "author": "John", "author_id": 30006, "author_profile": "https://Stackoverflow.com/users/30006", "pm_score": 0, "selected": false, "text": "object locker = new Object();\n\n....\n\nlock (locker)\n{\n //write xml file\n}\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
251,068
<p>Does a comparison sort have to compare the A[i] largest and A[i+1] largest values? I think any comparison sort must, but I'm not sure. I've checked out mergesort, insertion sort, and quicksort and in each of them the A[i] largest and A[i+1] largest values have to be compared.</p>
[ { "answer_id": 251127, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 1, "selected": false, "text": "A[i] > A[j] and A[j] > A[k] implies A[i] > A[k].\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27884/" ]
251,069
<p>I having to downgrade my Oracle instance from 10g (10.1.0.2.0) to 9i (9.2.x.x.x). Not having planned on ever doing this, I didn't document 10g dependencies.</p> <p>What are some of the dependencies on 10g that I will have to address?</p> <p>Is there any type of query that I could perform to detect dependencies?</p> <p>Of course I'm hoping for a magic bullet, not sifting through volumes of feature additions to compare with 100 klocs of PL/SQL.</p> <p>By the way, we are not downgrading the database in place, we are migrating from a 10g instance to a separate 9i instance.</p>
[ { "answer_id": 251127, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 1, "selected": false, "text": "A[i] > A[j] and A[j] > A[k] implies A[i] > A[k].\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
251,090
<p>I like Vim's visual mode. <kbd>v</kbd> for highlight/select chars or lines, <kbd>Ctrl</kbd><kbd>v</kbd> for rectangle highlighting, as far as I know (I am a beginner). Is there any way to use visual mode to highlight last two chars, for example, on each line for some selected lines? The selected lines are in different length. Basically, I would like to find a quick way to remove the last two chars for some selected lines. Not sure I can use visual mode to highlight irregular area.</p>
[ { "answer_id": 251132, "author": "ryan_s", "author_id": 13728, "author_profile": "https://Stackoverflow.com/users/13728", "pm_score": 2, "selected": false, "text": ":10,20 normal $xx\n" }, { "answer_id": 251137, "author": "reedstrm", "author_id": 5430, "author_profile": "https://Stackoverflow.com/users/5430", "pm_score": 3, "selected": false, "text": " :s/..$//\n ..$ : :'<,'>\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
251,104
<p>Windows Vista has "Presentation Mode", which you can turn on with the Mobility Center.</p> <p>How can I turn it on programmatically?</p>
[ { "answer_id": 10632946, "author": "fmuecke", "author_id": 105643, "author_profile": "https://Stackoverflow.com/users/105643", "pm_score": 3, "selected": true, "text": "presentationsettings.exe /start /stop" }, { "answer_id": 37039715, "author": "Bewc", "author_id": 1370448, "author_profile": "https://Stackoverflow.com/users/1370448", "pm_score": 1, "selected": false, "text": "PresentationSettings PresentationSettings /start PresentationSettings /stop Start-Process cmd -ArgumentList \"/c PresentationSettings\" Start-Process cmd -ArgumentList \"/c PresentationSettings /start\" -NoNewWindow Start-Process cmd -ArgumentList \"/c PresentationSettings /stop\" -NoNewWindow" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8446/" ]
251,110
<p>I tried this:</p> <pre><code>ALTER TABLE My.Table DROP MyField </code></pre> <p>and got this error:</p> <p>-MyField is not a constraint.</p> <p>-Could not drop constraint. See previous errors.</p> <p>There is just one row of data in the table and the field was just added.</p> <p><strong>EDIT:</strong> Just to follow up, the sql was missing COLUMN indeed. Now I get even more seriously looking errors though:</p> <ul> <li>The object 'some_object__somenumbers' is dependent on column 'MyField'</li> <li>ALTER TABLE DROP COLUMN MyField failed because one or more objects access this column.</li> </ul> <p><strong>EDIT:</strong></p> <pre><code>ALTER TABLE TableName DROP Constraint ConstraintName </code></pre> <p>worked, after that I was able to use the previous code to remove the column. Credit goes to both of you, thanks.</p>
[ { "answer_id": 251114, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 3, "selected": false, "text": "ALTER TABLE TableName DROP COLUMN ColumnName\n ALTER TABLE TableName DROP ConstraintName\n DROP INDEX TableName.IndexName\n" }, { "answer_id": 251184, "author": "Lance McNearney", "author_id": 25549, "author_profile": "https://Stackoverflow.com/users/25549", "pm_score": 3, "selected": true, "text": "ALTER TABLE TableName DROP ConstraintName\n" }, { "answer_id": 2537365, "author": "SAI", "author_id": 304137, "author_profile": "https://Stackoverflow.com/users/304137", "pm_score": 0, "selected": false, "text": "ALTER TABLE TABLE_NAME ADD COLUMN SR_NO INTEGER(10)NOT NULL;\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2631856/" ]
251,115
<p>I am working on a project where I search through a large text file (large is relative, file size is about 1 Gig) for a piece of data. I am looking for a token and I want a dollar value immediately after that token. For example,</p> <p>this is the token 9,999,999.99</p> <p>So here's is how I am approaching this problem. After a little analysis it appears that the token is usually near the end of the file so I thought I would start searching from the end of the file. Here is the code I have so far (vb.net):</p> <pre><code> Dim sToken As String = "This is a token" Dim sr As New StreamReader(sFileName_IN) Dim FileSize As Long = GetFileSize(sFileName_IN) Dim BlockSize As Integer = CInt(FileSize / 1000) Dim buffer(BlockSize) As Char Dim Position As Long = -BlockSize Dim sBuffer As String Dim CurrentBlock As Integer = 0 Dim Value As Double Dim i As Integer Dim found As Boolean = False While Not found And CurrentBlock &lt; 1000 CurrentBlock += 1 Position = -CurrentBlock * BlockSize sr.BaseStream.Seek(Position, SeekOrigin.End) i = sr.ReadBlock(buffer, 0, BlockSize) sBuffer = New String(buffer) found = SearchBuffer(sBuffer, sToken, Value) End While </code></pre> <p>GetFileSize is a function that returns the filesize. SearchBuffer is a function that will search a string for the token. I am not familiar with regular expressions but will explore it for that function.</p> <p>Basically I read in a small chunk of the file search it and if I don't find it load another chunk and so on...</p> <p>Am I on the right track or is there a better way? </p>
[ { "answer_id": 9757796, "author": "Yes Man", "author_id": 1231202, "author_profile": "https://Stackoverflow.com/users/1231202", "pm_score": 0, "selected": false, "text": "Dim stream As New FileStream(\"something.txt\")\nDim findBytes As [Byte]() = BitConverter.GetBytes(\"whatever\")\nDim f As Integer = 0\n\n' remaining = Length - Position\nWhile stream.Length - stream.Position > 0\n If stream.ReadByte() = findBytes(f) Then\n If ++f >= findBytes.Length Then\n Console.WriteLine(stream.Position)\n Exit While\n End If\n Else\n f = 0\n End If\nEnd While\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
251,116
<p>I use Eclipse with "external" projects - i.e. projects created from existing source.</p> <p>Poking around in the workspace files, I cannot find any reference to these projects. My question is: how does Eclipse keep track of these projects?</p> <p>I'd like to be able to add such a project to the workspace automatically (by generating <code>.project</code> and <code>.classpath</code> files).</p>
[ { "answer_id": 251129, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 8, "selected": true, "text": "<workspace>\\.metadata\\.plugins\\org.eclipse.core.resources\\.projects\\\n <workspace>/.metadata/.plugins/org.eclipse.core.resources/.projects/\n metadata org.eclipse.core.resources\\.projects File -> Refresh" }, { "answer_id": 251163, "author": "Dave DiFranco", "author_id": 30547, "author_profile": "https://Stackoverflow.com/users/30547", "pm_score": 3, "selected": false, "text": ".metadata\\.plugins\\org.eclipse.core.resources\\.projects\\\n" }, { "answer_id": 2429939, "author": "Magne Land", "author_id": 292035, "author_profile": "https://Stackoverflow.com/users/292035", "pm_score": 4, "selected": false, "text": "<workspace>/.metadata/.plugins/org.eclipse.core.resources/.projects\n" }, { "answer_id": 24114078, "author": "Jeegar Patel", "author_id": 775964, "author_profile": "https://Stackoverflow.com/users/775964", "pm_score": 1, "selected": false, "text": "<workspace>\\.metadata\\.plugins\\org.eclipse.core.resources\\.projects\\\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16977/" ]
251,117
<p>So yeah, I'm a Java guy in this crazy iPhone world. When it comes to memory management I stiill don't have a very good idea of what I'm doing. </p> <p>I have an app that uses a navigation controller, and when it's time to go on to the next view I have code that looks like this:</p> <pre><code>UIViewController *myController = [[MyViewController alloc] initWithNibName:@"MyView" bundle:[NSBundle mainBundle]; [[self navigationController] pushViewController:myController animated:YES]; </code></pre> <p>Now according to Apple's fundamental rule on memory management</p> <blockquote> <p>You take ownership of an object if you create it using a method whose name begins with “alloc” or “new” or contains “copy” (for example, <code>alloc</code>, <code>newObject</code>, or <code>mutableCopy</code>), or if you send it a <code>retain</code> message. You are responsible for relinquishing ownership of objects you own using <code>release</code> or <code>autorelease</code>. Any other time you receive an object, you must not release it.</p> </blockquote> <p>To me that means that I should be releasing <code>myController</code>, or giving it an <code>autorelease</code> message. But, whenever I try doing that my application winds up crashing as I push and pop views off of the stack. </p> <p>This didn't smell right to me, but in running Instruments it claims that I don't have any memory leaks. </p> <p>So I my question is</p> <ol> <li>Am I doing this right?</li> <li>Is the Navigation Controller taking ownership of MyViewController, explaining the lack of a memory leak?</li> <li>Should I assign myController to an instance variable in my root ViewController? In that case it would be marked retain and I would release in the root's dealloc method</li> </ol>
[ { "answer_id": 251233, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 3, "selected": false, "text": "-release -autorelease" }, { "answer_id": 251847, "author": "dnolen", "author_id": 32797, "author_profile": "https://Stackoverflow.com/users/32797", "pm_score": 3, "selected": true, "text": "[[[object alloc] init] autorelease];\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
251,155
<p>I am developing an iPhone application that persists data to a SQLite3 database. </p> <p>For each row I persist I wish to include a 'created date' and a 'last modified date'</p> <p>My question is what is the recommend approach for storing this information in a table? </p> <p>The properties are represented as NSDate in my application but I am unsure how to represent this information in my table.</p> <p>It appears that SQLite3 provides a DATETIME type but does not have a native understanding of how to parse this information.</p> <p>Any help would be much appreciated.</p> <p>Thanks in advance.</p>
[ { "answer_id": 251197, "author": "drewh", "author_id": 1967, "author_profile": "https://Stackoverflow.com/users/1967", "pm_score": 5, "selected": true, "text": "sqlite3_bind_double(statement, index, [dateObject timeIntervalSince1970]);\n [NSDate dateWithTimeIntervalSince1970:doubleValueFromDatabase];\n" }, { "answer_id": 251371, "author": "Marco", "author_id": 30480, "author_profile": "https://Stackoverflow.com/users/30480", "pm_score": 3, "selected": false, "text": "- timeIntervalSince1970\n- dateWithTimeIntervalSince1970:(double)value\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3596/" ]
251,159
<p>In C++, a function's signature depends partly on whether or not it's const. This means that a class can have two member functions with identical signatures except that one is const and the other is not. If you have a class like this, then the compiler will decide which function to call based on the object you call it on: if it's a const instance of the class, the const version of the function will be called; if the object isn't const, the other version will be called.</p> <p>In what circumstances might you want to take advantage of this feature?</p>
[ { "answer_id": 59016421, "author": "user265906", "author_id": 9528554, "author_profile": "https://Stackoverflow.com/users/9528554", "pm_score": -1, "selected": false, "text": "#include <iostream>\nusing namespace std;\nclass base\n{\n\npublic:\nvoid fun() const\n{\n cout<<\"have fun\";\n}\nvoid fun()\n{\n cout<<\"non const\";\n}\n\n};\nint main()\n{\n base b1;\n b1.fun(); //does not give error\n return 0;\n}\n const this const this*" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11575/" ]
251,181
<p>I have a DTS package that drops a table then creates it and populates it but sometimes something happens and the package fails after the drop table. If it's rerun it fails cuz the table hasn't been created yet. </p> <p>Is there something like "if exists" for SQLServer 2000 like in MySQL?</p> <p>thanks.</p>
[ { "answer_id": 251190, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 3, "selected": false, "text": "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TableName]') AND type in (N'U'))\nDROP TABLE TableName;\nGO\n" }, { "answer_id": 251206, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 1, "selected": false, "text": "IF EXISTS( SELECT * FROM dbo.sysobjects where id = object_id(N'TABLENAME') AND OBJECTPROPERTY(id, N'IsTable') = 1)\nBEGIN\n DROP TABLE TABLENAME\nEND\n" }, { "answer_id": 251210, "author": "Bob Probst", "author_id": 12424, "author_profile": "https://Stackoverflow.com/users/12424", "pm_score": 6, "selected": true, "text": "IF OBJECT_ID('temp_ARCHIVE_RECORD_COUNTS') IS NOT NULL \n DROP TABLE temp_ARCHIVE_RECORD_COUNTS \n" }, { "answer_id": 251219, "author": "user8605", "author_id": 8605, "author_profile": "https://Stackoverflow.com/users/8605", "pm_score": 2, "selected": false, "text": "IF OBJECT_ID('YOURTABLENAME') IS NOT NULL YOURTABLENAME tempdb.# OBJECT_ID" }, { "answer_id": 251376, "author": "Blorgbeard", "author_id": 369, "author_profile": "https://Stackoverflow.com/users/369", "pm_score": 3, "selected": false, "text": "if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME='MyTable') \nbegin \n drop table MyTable\nend\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
251,198
<p>I am developing a C# program, and i have one function that consumes too much CPU. I would like to know a way to control this by code (not with any external application) and restrict the percentage of CPU usage. For example, if it uses 90% of the CPU usage, to make my app consume only a 20%, even if it becomes slower. It must be done automatically and from within the app. If you provide a class, it would be fantastic.</p>
[ { "answer_id": 251220, "author": "dpurrington", "author_id": 5573, "author_profile": "https://Stackoverflow.com/users/5573", "pm_score": 5, "selected": true, "text": "Thread.CurrentThread.Priority = ThreadPriority.Lowest;\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31791/" ]
251,204
<p>I want to fade out an element and all its child elements after a delay of a few seconds. but I haven't found a way to specify that an effect should start after a specified time delay.</p>
[ { "answer_id": 251214, "author": "swilliams", "author_id": 736, "author_profile": "https://Stackoverflow.com/users/736", "pm_score": 7, "selected": true, "text": "setTimeout(function() { $('#foo').fadeOut(); }, 5000);\n" }, { "answer_id": 454387, "author": "Sampson", "author_id": 54680, "author_profile": "https://Stackoverflow.com/users/54680", "pm_score": 1, "selected": false, "text": "$(\"#hideAfterFiveSeconds\").click(function(){\n $(this).fadeTo(5000,1,function(){\n $(this).fadeOut(\"slow\");\n });\n});\n" }, { "answer_id": 552551, "author": "Simon_Weaver", "author_id": 16940, "author_profile": "https://Stackoverflow.com/users/16940", "pm_score": 5, "selected": false, "text": "$.fn.pause = function(duration) {\n $(this).animate({ dummy: 1 }, duration);\n return this;\n};\n $(\"#mainImage\").pause(5000).fadeOut();\n" }, { "answer_id": 2069155, "author": "Drew", "author_id": 217965, "author_profile": "https://Stackoverflow.com/users/217965", "pm_score": 4, "selected": false, "text": "$('#foo').animate({opacity: 1},1000).fadeOut('slow');\n $('#foo').delay(1000).fadeOut('slow');\n jQuery.delay()" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
251,218
<p>I'm using Wise Package Studio 7.0 SP2 on Windows XP.</p> <p>I've got an MSI Wrapped EXE installation that goes about happily installing some files and then running one of the files from the installation which we can refer to as app.exe.</p> <p>So on the "Execute Deferred" tab of the MSI Editor, I had to add the lines:</p> <pre><code>If Not Installed then Execute Installed Program app.exe (Action) End </code></pre> <p>This ensured that my app.exe would be run <em>only</em> on an installation and not during a modify/repair/removal. When app.exe runs, it conveniently adds itself to the system tray.</p> <p>I'm looking for something that will do the reverse during a removal. I want to stop the app.exe process thus removing it from the system tray.</p> <p>Currently my removal gets rid of all the files however the app.exe remains running and still shows up in the systems tray. I've looked at adding the conditional statement:</p> <pre><code>If REMOVE~="ALL" then *remove the app from the systray!* End </code></pre> <p>The conditional statement will let me do something only on a removal, however I'm not sure of the best approach to go about actually terminating the process. Is there an MSI command I can run that will let me do that? Should I write my own .exe that will do that?</p>
[ { "answer_id": 252627, "author": "Froosh", "author_id": 26000, "author_profile": "https://Stackoverflow.com/users/26000", "pm_score": 0, "selected": false, "text": "strMachine = \"localhost\"\nstrAppName = \"notepad.exe\"\n\nSet objProcesses = GetObject(\"winmgmts://\" & strMachine).ExecQuery(\"SELECT * FROM Win32_Process WHERE Caption LIKE '\" & strAppName & \"'\")\n\nFor Each objProcess In objProcesses\n intRetVal = objProcess.Terminate(0)\nNext\n" }, { "answer_id": 252769, "author": "saschabeaumont", "author_id": 592, "author_profile": "https://Stackoverflow.com/users/592", "pm_score": 3, "selected": true, "text": "TASKKILL /IM app.exe /F pskill.exe" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26853/" ]
251,225
<p>We have a large application in Ruby on Rails with many filters. Some of these filters can be complex. I am looking for a way to individually test these filters with a unit test. Right now I test them by testing them through an action that uses them with a functional test. This just doesn't feel like the right way.<br> Does anyone have advice or experience with this?</p>
[ { "answer_id": 251616, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 2, "selected": false, "text": "class SomeController\n before_filter :ensure_awesomeness\n\n ...\nend\n SomeController.new.ensure_awesomeness\n" }, { "answer_id": 251981, "author": "scottd", "author_id": 5935, "author_profile": "https://Stackoverflow.com/users/5935", "pm_score": 0, "selected": false, "text": "SomeController.new.send(:some_filter)\n" }, { "answer_id": 26382339, "author": "Bruno Mucelini Mergen", "author_id": 2441745, "author_profile": "https://Stackoverflow.com/users/2441745", "pm_score": 1, "selected": false, "text": "require \"test_helper\"\ndescribe ApplicationController do\n\n context 'ensure_manually_set_password' do\n setup do\n class ::TestingController < ApplicationController\n def hello\n render :nothing => true\n end\n end\n\n NameYourApp::Application.routes.draw do \n get 'hello', to: 'testing#hello', as: :hello\n end\n end\n\n after do\n Rails.application.reload_routes!\n end\n\n teardown do\n Object.send(:remove_const, :TestingController)\n end\n\n context 'when user is logged in' do\n setup do\n @controller = TestingController.new\n end\n\n context 'and user has not manually set their password' do\n let(:user) { FactoryGirl.build(:user, manually_set_password: false) }\n setup do\n login_as user\n get :hello\n end\n\n should 'redirect user to set their password' do\n assert_redirected_to new_password_path(user.password_token)\n end\n end\n end\n end\nend\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5935/" ]
251,243
<p>I'm trying to figure out why my app's TCP/IP connection keeps hiccuping every 10 minutes (exactly, within 1-2 seconds). I ran Wireshark and discovered that after 10 minutes of inactivity the other end is sending a packet with the reset (RST) flag set. A google search tells me "the RESET flag signifies that the receiver has become confused and so wants to abort the connection" but that is a little short of the detail I need. What could be causing this? And is it possible that some router along the way is responsible for it or would this always come from the other endpoint?</p> <p><strong>Edit:</strong> There is a router (specifically a Linksys WRT-54G) sitting between my computer and the other endpoint -- is there anything I should look for in the router settings?</p>
[ { "answer_id": 1172103, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "RST" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
251,246
<p>Ok I have an <code>apache IBM HTTP Server WAS 6.1</code> setup </p> <p>I have my <code>certs</code> correctly installed and can successfully load <code>http</code> and <code>https</code> pages.</p> <p>After a successful <code>j_security_check</code> authentication via <code>https</code>, I want the now authorized page (and all subsequent pages) to load as <code>http</code>.</p> <p>I want this all to work with <code>mod_rewrite</code> because I don't want to change application code for something that really should be simple to do on the webserver.</p> <p>I would think this would work but it doesn't and I fear it's because <code>j_security_check</code> is bypassing <code>mod_rewrite</code> somehow.</p> <pre><code>RewriteCond %{HTTPS} =off RewriteCond %{THE_REQUEST} login\.jsp.*action=init [OR] RewriteCond %{THE_REQUEST} login\.jsp.*action=submit RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] &lt;&lt;-- this rule is working RewriteCond %{HTTPS} =on RewriteCond %{THE_REQUEST} !login\.jsp.*action=init [OR] RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R,L] &lt;--- this rule is not working or the condition is not returning true </code></pre> <p>I know the <code>[R,L]</code> will force the executed rule to be the last rule to run on a request and redirect accordingly.</p> <p>I found this little jewel after a little googleing.</p> <pre><code>mod_rewrite: My rules are ignored. Nothing is written to the rewrite log. The most common cause of this is placing mod_rewrite directives at global scope (outside of any VirtualHost containers) but expecting the directives to apply to requests which were matched by a VirtualHost container. In this example, the mod_rewrite configuration will be ignored for requests which are received on port 443: RewriteEngine On RewriteRule ^index.htm$ index.html &lt;VirtualHost *:443&gt; existing vhost directives &lt;/VirtualHost&gt; Unlike most configurable features, the mod_rewrite configuration is not inherited by default within a &lt;VirtualHost &gt; container. To have global mod_rewrite directives apply to a VirtualHost, add these two extra directives to the VirtualHost container: &lt;VirtualHost *:443&gt; existing vhost directives RewriteEngine On RewriteOptions Inherit &lt;/VirtualHost&gt; </code></pre> <p>Adding the Inherit declaration to my single <code>virtualhost</code> declaration that points to the machine ip and <code>port 443</code> did NOT help one bit.</p> <p>Now I know that my app server communicates on <code>9080</code> and <code>9443</code> respectively but I can't find a single <code>virtualhost</code> in the web server <code>httpd.conf</code>. </p> <p>I did some testing with different rewrite rules while not authenticated and saw that my <code>mod rewrite</code> code worked.. </p> <p><strong>So: how do I make websphere use mod rewrite after authentication?</strong> </p> <p>It's like the web server is only used for unauthenticated requests and after that some blackbox container serves up everything somehow.</p>
[ { "answer_id": 251871, "author": "Maglob", "author_id": 27520, "author_profile": "https://Stackoverflow.com/users/27520", "pm_score": -1, "selected": false, "text": "RewriteCond %{THE_REQUEST} !login\\.jsp.*action=init\nRewriteCond %{THE_REQUEST} !login\\.jsp.*action=submit\n" }, { "answer_id": 253765, "author": "branchgabriel", "author_id": 30807, "author_profile": "https://Stackoverflow.com/users/30807", "pm_score": 1, "selected": true, "text": "RewriteEngine on\nRewriteCond %{HTTPS} !=on\nRewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\\ /path/login\\.jsp\\ HTTP/1\\.1\nRewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]\n\n <VirtualHost 000.000.000.000:443>\n ServerName servername\n ServerAlias url.com machinename\n DocumentRoot d:/ibmhttpserver61/htdocs/en_US\n ErrorLog d:/ibmhttpserver61/logs/secerr.log\n TransferLog d:/ibmhttpserver61/logs/sectrans.log\n SSLEnable\n Keyfile d:/ibmhttpserver61/ssl/ctxroot.kdb\n SSLV2Timeout 100\n SSLV3Timeout 1000 \n\n RewriteEngine On\n RewriteCond %{REQUEST_URI} /path/secure/index.jsf\n RewriteRule ^(.*)$ http://url/path/secure/index.jsf [R,L] \n\n </VirtualHost>\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30807/" ]
251,248
<p>I am looking for an easy way to get the SID for the current Windows user account. I know I can do it through WMI, but I don't want to go that route.</p> <p>Apologies to everybody that answered in C# for not specifying it's C++. :-)</p>
[ { "answer_id": 251267, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 7, "selected": true, "text": "TokenUser IPrincipal principal = Thread.CurrentPrincipal;\nWindowsIdentity identity = principal.Identity as WindowsIdentity;\nif (identity != null)\n Console.WriteLine(identity.User);\n WindowsIdentity identity = WindowsIdentity.GetCurrent();\nif (identity != null)\n Console.WriteLine(identity.User);\n" }, { "answer_id": 251308, "author": "silverbugg", "author_id": 29650, "author_profile": "https://Stackoverflow.com/users/29650", "pm_score": 2, "selected": false, "text": "using Microsoft.Win32.Security; string username = Environment.UserName + \"@\" + Environment.GetEnvironmentVariable(\"USERDNSDOMAIN\"); Sid sidUser = new Sid (username); using System.Security.AccessControl; using System.Security.Principal; WindowsIdentity m_Self = WindowsIdentity.GetCurrent(); SecurityIdentifier m_SID = m_Self.Owner;\");" }, { "answer_id": 8850569, "author": "cigar huang", "author_id": 659882, "author_profile": "https://Stackoverflow.com/users/659882", "pm_score": 2, "selected": false, "text": "System.Security.Principal.WindowsIdentity id = System.Security.Principal.WindowsIdentity.GetCurrent();\nstring sid = id.User.AccountDomainSid.ToString();\n" }, { "answer_id": 13032855, "author": "nullpotent", "author_id": 661797, "author_profile": "https://Stackoverflow.com/users/661797", "pm_score": 0, "selected": false, "text": "UserPrincipal.Current.Sid;\n" }, { "answer_id": 13356252, "author": "dex black", "author_id": 635976, "author_profile": "https://Stackoverflow.com/users/635976", "pm_score": 3, "selected": false, "text": "ATL::CAccessToken accessToken;\nATL::CSid currentUserSid;\nif (accessToken.GetProcessToken(TOKEN_READ | TOKEN_QUERY) &&\n accessToken.GetUser(&currentUserSid))\n return currentUserSid.Sid();\n" }, { "answer_id": 45717256, "author": "Ian Boyd", "author_id": 12597, "author_profile": "https://Stackoverflow.com/users/12597", "pm_score": 1, "selected": false, "text": "function GetCurrentUserSid: string;\n\n hAccessToken: THandle;\n userToken: PTokenUser;\n dwInfoBufferSize: DWORD;\n dw: DWORD;\n\n if not OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, ref hAccessToken) then\n dw <- GetLastError;\n if dw <> ERROR_NO_TOKEN then\n RaiseLastOSError(dw);\n\n if not OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, ref hAccessToken) then\n RaiseLastOSError;\n try\n userToken <- GetMemory(1024);\n try\n if not GetTokenInformation(hAccessToken, TokenUser, userToken, 1024, ref dwInfoBufferSize) then\n RaiseLastOSError;\n Result <- SidToString(userToken.User.Sid);\n finally\n FreeMemory(userToken);\n finally\n CloseHandle(hAccessToken);\n" }, { "answer_id": 53256910, "author": "BattleTested_закалённый в бою", "author_id": 4134099, "author_profile": "https://Stackoverflow.com/users/4134099", "pm_score": 1, "selected": false, "text": "c++ c++ powershell SID system-pc1 Get-WmiObject win32_useraccount -Filter \"name = 'system-pc1'\" | Select-Object sid\n username code char username[UNLEN+1];\nDWORD username_len = UNLEN+1;\nGetUserName(username, &username_len);\n WQL c++ system-pc1 WQL_WIN32_USERACCOUNT_QUERY #define NETWORK_RESOURCE \"root\\\\CIMV2\"\n#define WQL_LANGUAGE \"WQL\"\n#define WQL_WIN32_USERACCOUNT_QUERY \"SELECT * FROM Win32_Useraccount where name='system-pc1'\"\n#define WQL_SID \"SID\"\n\nIWbemLocator *pLoc = 0; // Obtain initial locator to WMI to a particular host computer\nIWbemServices *pSvc = 0; // To use of connection that created with CoCreateInstance()\nULONG uReturn = 0;\nHRESULT hResult = S_OK; // Result when we initializing\nIWbemClassObject *pClsObject = NULL; // A class for handle IEnumWbemClassObject objects\nIEnumWbemClassObject *pEnumerator = NULL; // To enumerate objects\nVARIANT vtSID = { 0 }; // OS name property\n\n// Initialize COM library\nhResult = CoInitializeEx(0, COINIT_MULTITHREADED);\nif (SUCCEEDED(hResult))\n{\n // Initialize security\n hResult = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT,\n RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);\n if (SUCCEEDED(hResult))\n {\n // Create only one object on the local system\n hResult = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,\n IID_IWbemLocator, (LPVOID*)&pLoc);\n\n if (SUCCEEDED(hResult))\n {\n // Connect to specific host system namespace\n hResult = pLoc->ConnectServer(TEXT(NETWORK_RESOURCE), NULL, NULL,\n 0, NULL, 0, 0, &pSvc);\n if (SUCCEEDED(hResult))\n {\n /* Set the IWbemServices proxy\n * So the impersonation of the user will be occurred */\n hResult = CoSetProxyBlanket(pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE,\n NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE,\n NULL, EOAC_NONE);\n if (SUCCEEDED(hResult))\n {\n /* Use the IWbemServices pointer to make requests of WMI\n * For example, query for user account */\n hResult = pSvc->ExecQuery(TEXT(WQL_LANGUAGE), TEXT(WQL_WIN32_USERACCOUNT_QUERY),\n WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);\n if (SUCCEEDED(hResult))\n {\n // Go to get the next object from IEnumWbemClassObject\n pEnumerator->Next(WBEM_INFINITE, 1, &pClsObject, &uReturn);\n if (uReturn != 0)\n {\n // Get the value of the \"sid, ...\" property\n pClsObject->Get(TEXT(WQL_SID), 0, &vtSID, 0, 0);\n VariantClear(&vtSID);\n\n // Print SID\n wcout << vtSID.bstrVal;\n\n pClsObject->Release();\n pClsObject = NULL;\n }\n }\n }\n }\n }\n }\n\n // Cleanup\n pSvc->Release();\n pLoc->Release();\n pEnumerator->Release();\n // Uninitialize COM library\n CoUninitialize();\n" } ]
2008/10/30
[ "https://Stackoverflow.com/questions/251248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17028/" ]