qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
160,298
<p>This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that.</p> <p>In Python, it's worth mentioning that the problem is somewhat related to <a href="https://stackoverflow.com/questions/773/how-do-i-use-pythons-itertoolsgroupby">how-do-i-use-pythons-itertoolsgroupby</a>.</p> <p>Suppose you're given two Django Model-derived classes:</p> <pre><code>from django.db import models class Car(models.Model): mods = models.ManyToManyField(Representative) </code></pre> <p>and</p> <pre><code>from django.db import models class Mods(models.Model): ... </code></pre> <p>How does one get a list of Cars, grouped by Cars with a common set of Mods?</p> <p>I.e. I want to get a class likeso:</p> <pre><code>Cars_by_common_mods = [ { mods: { 'a' }, cars: { 'W1', 'W2' } }, { mods: { 'a', 'b' }, cars: { 'X1', 'X2', 'X3' }, }, { mods: { 'b' }, cars: { 'Y1', 'Y2' } }, { mods: { 'a', 'b', 'c' }, cars: { 'Z1' } }, ] </code></pre> <p>I've been thinking of something like:</p> <pre><code>def cars_by_common_mods(): cars = Cars.objects.all() mod_list = [] for car in cars: mod_list.append( { 'car': car, 'mods': list(car.mods.all()) } ret = [] for key, mods_group in groupby(list(mods), lambda x: set(x.mods)): ret.append(mods_group) return ret </code></pre> <p>However, that doesn't work because (perhaps among other reasons) the groupby doesn't seem to group by the mods sets. I guess the mod_list has to be sorted to work with groupby. All to say, I'm confident there's something simple and elegant out there that will be both enlightening and illuminating.</p> <p><em>Cheers &amp; thanks!</em></p>
[ { "answer_id": 161082, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 3, "selected": true, "text": "import itertools\n\ncars = [\n {'car': 'X2', 'mods': [1,2]},\n {'car': 'Y2', 'mods': [2]},\n {'car': 'W2', 'm...
2008/10/01
[ "https://Stackoverflow.com/questions/160298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19212/" ]
160,304
<p>I am using sybase database to query the daily transaction report. I had subquery within my script. </p> <p>Here as it goes:</p> <pre><code>SELECT orders.accountid ,items.x,etc (SELECT charges.mistotal FROM charges where items.id = charges.id) FROM items,orders WHERE date = '2008-10-02' </code></pre> <p>Here I am getting the error message as:</p> <blockquote> <p><em>Subquery cannot return more than one values</em></p> </blockquote> <p>My values are 7.50, 25.00</p> <p>I want to return the 25.00, but when I use </p> <pre><code>(SELECT TOP 1 charges.mistotal FROM charges where items.id = charges.id) </code></pre> <p>My result is 7.50 but I want to return 25.00</p> <p>Does anyone has any better suggestion?</p>
[ { "answer_id": 160327, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 1, "selected": false, "text": "SELECT MAX(charges.mistotal) FROM charges WHERE items.id = charges.id\n" }, { "answer_id": 160338, "author":...
2008/10/02
[ "https://Stackoverflow.com/questions/160304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14752/" ]
160,313
<p>I'm working on a project where I'm trying to avoid hard-coding DB IDs in a .NET service-oriented project. There are some instances where I <strong>need</strong> to set ID values through code but I don't want to just hard code the IDs since I've done that before and it lead to DB alignment nightmares when the auto-incrementing IDs were changed when the DB was dumped to a new system.</p> <p>What I want to do is create an enumerated constants that store the IDs as so that at the worst, only 1 file has to be updated if the DB is ever changed instead of trying to go through thousands upon thousands of lines of code to replace any ID in the system.</p> <p>This will work on a single system, but in my company's service oriented environment, enumerations don't serialize with their values, just their names.</p> <p>What is the best way to share IDs across a web service? I'd like to use either enumerations (the ideal situation) or constants in some way, but I can't seem to get this to work. I could make a web method that returns the IDs, but sending a web request for every ID and then serializing the response and deserializing on the client machine just sounds like a bad idea.</p> <p><strong>EDIT</strong><br> I wasn't entirely clear about what I was asking, so I'll elaborate.</p> <p>I want to have a group of constants. The enum would only be used because it groups constants together appropriately. I'm mainly interested in see if there is a way to share constants across a web service. I need the values the enum represent, not the enum itself. The enum is never sent between the service and the client except as an integer. Internally everything is stored as an ID, not an enum.</p> <p>Having a separate shared library doesn't sound like the ideal solution since I'm almost at the completion point for this project and I'd only be storing 1 enum/class in the library. It seems like a bit of a waste to make for just one class.</p>
[ { "answer_id": 160446, "author": "Vivek", "author_id": 7418, "author_profile": "https://Stackoverflow.com/users/7418", "pm_score": 0, "selected": false, "text": "DayOfWeek ConvertToDayOfWeek(this String str)\n{\n return (DayOfWeek)Enum.Parse(typeof(DayOfWeek), str, true);\n}\n" }, ...
2008/10/02
[ "https://Stackoverflow.com/questions/160313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
160,315
<p>I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holding down the alt key at startup.</p> <p>Unfortunately, there is no obvious way to ask java whether a given key is <strong>currently being pressed</strong>. You can only register to be informed of new key presses via a KeyListener, but that doesn't help if the keypress starts before the app launches.</p>
[ { "answer_id": 160806, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 2, "selected": false, "text": "import java.awt.*;\nimport java.awt.event.*;\nimport javax.swing.JFrame;\n\npublic class LockingKeyDemo {\n static Toolk...
2008/10/02
[ "https://Stackoverflow.com/questions/160315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15255/" ]
160,318
<p>The kind of simulation game that I have in mind is the kind where you have things to build in various locations and workers/transporters that connect such locations.</p> <p>Something more like the Settlers series.</p> <p>Let's assume I don't want any graphics at the moment, <strong>that</strong> I think I can manage.</p> <p>So my doubts are the following:</p> <ol> <li>Should every entity be a class and each one have a thread?</li> <li>Should entities be grouped in lists inside classes and each one have a thread?</li> </ol> <p>If one takes implementation 1, it's going to be very hard to run on low spec machines and does not scale well for large numbers.</p> <p>If one takes implementation 2, it's going to be better in terms of resources but then...</p> <p>How should I group the entities?</p> <ol> <li>Have a class for houses in general and have an Interface List to manage that?</li> <li>Have a class for specific groups of houses and have an Object List to manage that?</li> </ol> <p>and what about threads?</p> <ol> <li>Should I have the simplistic main game loop?</li> <li>Should I have a thread for each class group?</li> <li>How do workers/transporters fit in the picture?</li> </ol>
[ { "answer_id": 160349, "author": "Zarkonnen", "author_id": 15255, "author_profile": "https://Stackoverflow.com/users/15255", "pm_score": 2, "selected": false, "text": "House" }, { "answer_id": 160356, "author": "Community", "author_id": -1, "author_profile": "https://...
2008/10/02
[ "https://Stackoverflow.com/questions/160318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8167/" ]
160,335
<p>I've been playing with the .NET built in localization features and they seem to all rely on putting data in resx files. </p> <p>But most systems can't rely on this because they are database driven. So how do you solve this issue? Is there a built in .NET way, or do you create a translations table in SQL and do it all manually? And if you have to do this on the majority of your sites, is there any reason to even use the resx way of localization?</p> <p>An example of this is I have an FAQ list on my site, I keep this list in the database so I can easily add/remove more, but by putting it in the database, I have no good way have translating this information into multiple languages.</p>
[ { "answer_id": 164253, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 2, "selected": false, "text": "Item (ItemID, ...)\nItemLocal (ItemID,LocaleID,....)\n" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17176/" ]
160,370
<p>In svn, I have a branch which was created, say at revision 22334. Commits were then made on the branch.</p> <p>How do I get a list of all files that were changed on the branch compared to what's on the trunk? I do not want to see files that were changed on the trunk between when the branch was created and "now".</p>
[ { "answer_id": 160395, "author": "andy", "author_id": 21482, "author_profile": "https://Stackoverflow.com/users/21482", "pm_score": 7, "selected": true, "text": "svn diff -r 22334:HEAD --summarize <url of the branch>\n" }, { "answer_id": 5207017, "author": "Robert Duchnik", ...
2008/10/02
[ "https://Stackoverflow.com/questions/160370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2601671/" ]
160,373
<pre><code>Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = "connect timeout=9999999;" &amp; _ "data source=" &amp; DefaultIserver &amp; ";" &amp; _ "initial catalog=" &amp; DefaultIdBase &amp; "; " &amp; _ "user id=userid;" &amp; _ "password=userpass;" &amp; _ "persist security info=True; " &amp; _ "packet size=4096" SQLconn.Open() SQLcmd.CommandType = CommandType.Text SQLcmd.CommandText = "Select distinct username, cast(convert(varchar,userpassword) as varchar) as 'userpassword' from " &amp; tblUsersList &amp; " where usertype='MainAdmin'" SQLcmd.Connection = SQLconn SQLreader = SQLcmd.ExecuteReader While SQLreader.Read = True CurrentAdminUser = SQLreader("username").ToString CurrentAdminPass = SQLreader("userpassword").ToString 'PROBLEM' End While Catch ex As Exception ErrorMessage(ex) Finally If SQLconn.State = ConnectionState.Open Then SQLconn.Close() If SQLreader.IsClosed = False Then SQLreader.Close() End Try End Function 'FillAdminAccount </code></pre> <p>Please see the line with the comment PROBLEM. On this code, the output is equal to <em>"userpassword</em>. As you can see, there is no quotation mark on the right and <strong>I wonder why</strong>. By the way, the data type of the userpassword in the database is BINARY. Wish you could help me on this. Thank you..x_x</p>
[ { "answer_id": 160396, "author": "oglester", "author_id": 2017, "author_profile": "https://Stackoverflow.com/users/2017", "pm_score": 1, "selected": false, "text": "as varchar) as 'userpassword'\n" }, { "answer_id": 160457, "author": "Herb Caudill", "author_id": 239663, ...
2008/10/02
[ "https://Stackoverflow.com/questions/160373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21963/" ]
160,376
<p>I've noticed that just in the last year or so, many major websites have made the same change to the way their pages are structured. Each has moved their Javascript files from being hosted on the same domain as the page itself (or a subdomain of that), to being hosted on a differently named domain.</p> <h2>It's not simply parallelization</h2> <p>Now, there is a well known technique of spreading the components of your page across multiple domains to parallelize downloading. <a href="http://developer.yahoo.com/performance/rules.html#split" rel="nofollow noreferrer">Yahoo recommends it</a> as do many others. For instance, <strong>www.example.com</strong> is where your HTML is hosted, then you put images on <strong>images.example.com</strong> and javascripts on <strong>scripts.example.com</strong>. This gets around the fact that most browsers limit the number of simultaneous connections per server in order to be good net citizens.</p> <p>The above is <em>not</em> what I am talking about.</p> <h2>It's not simply redirection to a content delivery network (or maybe it is--see bottom of question)</h2> <p>What I am talking about is hosting Javascripts specifically on an entirely different domain. Let me be specific. Just in the last year or so I've noticed that:</p> <p><strong>youtube.com</strong> has moved its .JS files to <strong>ytimg.com</strong></p> <p><strong>cnn.com</strong> has moved its .JS files to <strong>cdn.turner.com</strong></p> <p><strong>weather.com</strong> has moved its .JS files to <strong>j.imwx.com</strong></p> <p>Now, I know about content delivery networks like <a href="http://www.akamai.com" rel="nofollow noreferrer">Akamai</a> who specialize in outsourcing this for large websites. (The name "cdn" in Turner's special domain clues us in to the importance of this concept here).</p> <p>But note with these examples, each site has its own specifically registered domain for this purpose, and its not the domain of a content delivery network or other infrastructure provider. In fact, if you try to load the home page off most of these script domains, they usually redirect back to the main domain of the company. And if you reverse lookup the IPs involved, they <em>sometimes</em> appear point to a CDN company's servers, sometimes not.</p> <h2>Why do I care?</h2> <p>Having formerly worked at two different security companies, I have been made paranoid of malicious Javascripts.</p> <p>As a result, I follow the practice of whitelisting sites that I will allow Javascript (and other active content such as Java) to run on. As a result, to make a site like <strong>cnn.com</strong> work properly, I have to manually put <strong>cnn.com</strong> into a list. It's a pain in the behind, but I prefer it over the alternative.</p> <p>When folks used things like <strong>scripts.cnn.com</strong> to parallelize, that worked fine with appropriate wildcarding. And when folks used subdomains off the CDN company domains, I could just permit the CDN company's main domain with a wildcard in front as well and kill many birds with one stone (such as *.edgesuite.net and *.akamai.com).</p> <p>Now I have discovered that (as of 2008) this is not enough. Now I have to poke around in the source code of a page I want to whitelist, and figure out what "secret" domain (or domains) that site is using to store their Javascripts on. In some cases I've found I have to permit three different domains to make a site work.</p> <h2>Why did all these major sites start doing this?</h2> <p>EDIT: OK <a href="https://stackoverflow.com/questions/160376/why-move-your-javascript-files-to-a-different-main-domain-that-you-also-own#160451">as "onebyone" pointed out</a>, it does appear to be related to CDN delivery of content. So let me modify the question slightly based on his research...</p> <p>Why is <strong>weather.com</strong> using <strong>j.imwx.com</strong> instead of <strong>twc.vo.llnwd.net</strong>?</p> <p>Why is <strong>youtube.com</strong> using <strong>s.ytimg.com</strong> instead of <strong>static.cache.l.google.com</strong>?</p> <p>There has to a reasoning behind this.</p>
[ { "answer_id": 160451, "author": "Steve Jessop", "author_id": 13005, "author_profile": "https://Stackoverflow.com/users/13005", "pm_score": 2, "selected": false, "text": "$ host j.imwx.com\nj.imwx.com CNAME twc.vo.llnwd.net\ntwc.vo.llnwd.net A 87.248.211.218\n...
2008/10/02
[ "https://Stackoverflow.com/questions/160376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4425/" ]
160,391
<p>I've got a ListBox control and I'm presenting a fixed number of ListBoxItem objects in a grid layout. So I've set my ItemsPanelTemplate to be a Grid.</p> <p>I'm accessing the Grid from code behind to configure the RowDefinitions and ColumnDefinitions.</p> <p>So far it's all working as I expect. I've got some custom IValueConverter implementations for returning the Grid.Row and Grid.Column that each ListBoxItem should appear in.</p> <p>However I get weird binding errors sometimes, and I can't figure out exactly why they're happening, or even if they're in my code.</p> <p>Here's the error I get:</p> <blockquote> <p><code>System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ListBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')</code></p> </blockquote> <p>Can anybody explain what's going on?</p> <p>Oh, and, here's my XAML:</p> <pre><code>&lt;UserControl.Resources&gt; &lt;!-- Value Converters --&gt; &lt;v:GridRowConverter x:Key="GridRowConverter" /&gt; &lt;v:GridColumnConverter x:Key="GridColumnConverter" /&gt; &lt;v:DevicePositionConverter x:Key="DevicePositionConverter" /&gt; &lt;v:DeviceBackgroundConverter x:Key="DeviceBackgroundConverter" /&gt; &lt;Style x:Key="DeviceContainerStyle" TargetType="{x:Type ListBoxItem}"&gt; &lt;Setter Property="FocusVisualStyle" Value="{x:Null}" /&gt; &lt;Setter Property="Background" Value="Transparent" /&gt; &lt;Setter Property="Grid.Row" Value="{Binding Path=DeviceId, Converter={StaticResource GridRowConverter}}" /&gt; &lt;Setter Property="Grid.Column" Value="{Binding Path=DeviceId, Converter={StaticResource GridColumnConverter}}" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ListBoxItem}"&gt; &lt;Border CornerRadius="2" BorderThickness="1" BorderBrush="White" Margin="2" Name="Bd" Background="{Binding Converter={StaticResource DeviceBackgroundConverter}}"&gt; &lt;TextBlock FontSize="12" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Path=DeviceId, Converter={StaticResource DevicePositionConverter}}" &gt; &lt;TextBlock.LayoutTransform&gt; &lt;RotateTransform Angle="270" /&gt; &lt;/TextBlock.LayoutTransform&gt; &lt;/TextBlock&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsSelected" Value="true"&gt; &lt;Setter TargetName="Bd" Property="BorderThickness" Value="2" /&gt; &lt;Setter TargetName="Bd" Property="Margin" Value="1" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/UserControl.Resources&gt; &lt;Border CornerRadius="3" BorderThickness="3" Background="#FF333333" BorderBrush="#FF333333" &gt; &lt;Grid ShowGridLines="False"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="15" /&gt; &lt;RowDefinition Height="*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;StackPanel Grid.Row="0" Orientation="Horizontal"&gt; &lt;Image Margin="20,3,3,3" Source="Barcode.GIF" Width="60" Stretch="Fill" /&gt; &lt;/StackPanel&gt; &lt;ListBox ItemsSource="{Binding}" x:Name="lstDevices" Grid.Row="1" ItemContainerStyle="{StaticResource DeviceContainerStyle}" Background="#FF333333" SelectedItem="{Binding SelectedDeviceResult, ElementName=root, Mode=TwoWay}" &gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;Grid&gt; &lt;Grid.LayoutTransform&gt; &lt;RotateTransform Angle="90" /&gt; &lt;/Grid.LayoutTransform&gt; &lt;/Grid&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;/ListBox&gt; &lt;/Grid&gt; &lt;/Border&gt; </code></pre> <p></p>
[ { "answer_id": 163728, "author": "Joel B Fant", "author_id": 22211, "author_profile": "https://Stackoverflow.com/users/22211", "pm_score": 1, "selected": false, "text": "DataTemplates" }, { "answer_id": 176410, "author": "ligaz", "author_id": 6409, "author_profile": "...
2008/10/02
[ "https://Stackoverflow.com/questions/160391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
160,433
<p>One of your team members has been appointed "technical lead" or "team lead" yet he is technically incompetent and lacks major leadership skills.</p> <p>By technically incompetent, I mean that the person doesn't know the difference between an abstract class and an interface, doesn't understand why coupling should be avoided, doesn't understand the concept of cohesion, provides solutions without taking some time to think, doesn't understand why we should favor composition over inheritance and doesn't get design patterns (except the singleton pattern).</p> <p>Plus that person has over 10 years of "experience" (yes, I did put that word in quotes because he's given a whole different dimension of what experience really is).</p> <p>I'm dealing with such a person at work. It's taking away the passion I have for this profession.</p> <p>How do you react? What do you do?</p>
[ { "answer_id": 593500, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 1, "selected": false, "text": "public byte[] ReadBytes(string filename)\n{\n FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);\n ...
2008/10/02
[ "https://Stackoverflow.com/questions/160433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24346/" ]
160,453
<p>I have two tables: <code>foos</code> and <code>bars</code>, and there is a many-to-one relationship between them: each <code>foo</code> can have many <code>bars</code>. I also have a view <code>foobars</code>, which joins these two tables (its query is like <code>select foo.*, bar.id from foos, bars where bar.foo_id=foo.id</code>).</p> <p>EDIT: You would not be wrong if you said that there's a many-to-many relationship between <code>foo</code>s and <code>bar</code>s. A <code>bar</code>, however, is just a tag (in fact, it is a size), and consists just of its name. The table <code>bars</code> has the same role as a link table would have.</p> <p>I have a rule on inserting to <code>foobars</code> such that the “foo” part is inserted to <code>foos</code> as a new row, and “bar” part, which consists of a couple of bar-id's separated by commas is split, and for each such part a link between it and the appropriate <code>foo</code> is created (I use a procedure to do that).</p> <p>This works great for inserts. I have a problem, however, when it comes to updating the whole thing. The <code>foo</code> part of the rule is easy. However, I don't know how to deal with the multiple <code>bar</code>s part. When I try to do something like <code>DELETE FROM bars WHERE foo_id=new.foo_id</code> in the rule, I end deleting everything from the table <code>bars</code>.</p> <p>What am I doing wrong? Is there a way of achieving what I need? Finally, is my approach to the whole thing sensible?</p> <p>(I do this overcomplicated thing with the view because the data I get is in the form of “<code>foo</code> and all its <code>bar</code>s”, but the user must see just <code>foobars</code>.)</p>
[ { "answer_id": 160616, "author": "Michał Niedźwiedzki", "author_id": 2169, "author_profile": "https://Stackoverflow.com/users/2169", "pm_score": 2, "selected": false, "text": "foos" }, { "answer_id": 164275, "author": "Ryszard Szopa", "author_id": 19922, "author_profi...
2008/10/02
[ "https://Stackoverflow.com/questions/160453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19922/" ]
160,467
<p>I need to create an ODBC link from an Access 2003 (Jet) database to a SQL Server hosted view which contains aliased field names containing periods such as:</p> <pre><code>Seq.Group </code></pre> <p>In the SQL source behind the view, the field names are encased in square brackets...</p> <pre><code>SELECT Table._Group AS [Seq.Group] </code></pre> <p>...so SQL Server doesn't complain about creating the view, but when I try to create an ODBC link to it from the Jet DB (either programmatically or via the Access 2003 UI) I receive the error message:</p> <blockquote> <p>'Seq.Group' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.</p> </blockquote> <p>Unfortunately, I cannot modify the structure of the view because it's part of another product, so I am stuck with the field names the way that they are. I <em>could</em> add my own view with punctuation-free field names, but I'd really rather not modify the SQL Server at all because then that becomes another point of maintenance every time there's an upgrade, hotfix, etc. Does anyone know a better workaround?</p>
[ { "answer_id": 161015, "author": "Philippe Grondier", "author_id": 11436, "author_profile": "https://Stackoverflow.com/users/11436", "pm_score": 0, "selected": false, "text": "SELECT Table._Group AS [Seq_Group]\n" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3469/" ]
160,494
<pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericCount { class Program { static int Count1&lt;T&gt;(T a) where T : IEnumerable&lt;T&gt; { return a.Count(); } static void Main(string[] args) { List&lt;string&gt; mystring = new List&lt;string&gt;() { "rob","tx" }; int count = Count1&lt;List&lt;string&gt;&gt;(mystring);****** Console.WriteLine(count.ToString()); } } } </code></pre> <p>What do I have to change in the above indicated line of code to make it work. I am just trying to pass either List or array in order to get the count. </p>
[ { "answer_id": 160570, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 3, "selected": true, "text": "static int Count1<T>(IEnumerable<T> a)\n{\n return a.Count();\n}\n" }, { "answer_id": 160584, "author": "Jon C...
2008/10/02
[ "https://Stackoverflow.com/questions/160494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
160,497
<p>I'm using subversion (TortoiseSVN) and I want to remove the .svn folders from my project for deployment, is there an automated way of doing this using subversion or do I have to create a custom script for this?</p>
[ { "answer_id": 160502, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackoverflow.com/users/8123", "pm_score": 5, "selected": false, "text": "svn export <url-to-repo> <dest-path>\n" }, { "answer_id": 160503, "author": "nobody", "author_id": 19405, ...
2008/10/02
[ "https://Stackoverflow.com/questions/160497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
160,514
<p>Are there are good uses of Partial Classes outside the webforms/winforms generated code scenarios? Or is this feature basically to support that?</p>
[ { "answer_id": 160825, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 0, "selected": false, "text": "#region" }, { "answer_id": 228442, "author": "David Boike", "author_id": 10039, "author_profile": "h...
2008/10/02
[ "https://Stackoverflow.com/questions/160514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
160,519
<p>Can this be done w/ linqtosql?</p> <pre><code>SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP BY City </code></pre>
[ { "answer_id": 160825, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 0, "selected": false, "text": "#region" }, { "answer_id": 228442, "author": "David Boike", "author_id": 10039, "author_profile": "h...
2008/10/02
[ "https://Stackoverflow.com/questions/160519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3396/" ]
160,532
<p>I want to export the contents of several tables from MSAccess2003. The tables contain unicode Japanese characters. I want to store them as tilde delimited text files.</p> <p>I can do this manually using File/Export and, in the 'Advanced' dialog selecting tilde as Field Delimiter and the Unicode as the Code Page.</p> <p>I can store this as an Export Specification, but this seems to be table specific.</p> <p>I want to export many tables using VBA Code.</p> <p>So far I have tried:</p> <p>Sub ExportTables()</p> <pre><code>Dim lTbl As Long Dim dBase As Database Dim TableName As String Set dBase = CurrentDb For lTbl = 0 To dBase.TableDefs.Count 'If the table name is a temporary or system table then ignore it If Left(dBase.TableDefs(lTbl).Name, 1) = "~" Or _ Left(dBase.TableDefs(lTbl).Name, 4) = "MSYS" Then '~ indicates a temporary table 'MSYS indicates a system level table Else TableName = dBase.TableDefs(lTbl).Name DoCmd.TransferText acExportDelim, "UnicodeTilde", TableName, "c:\" + TableName + ".txt", True End If Next lTbl Set dBase = Nothing </code></pre> <p>End Sub</p> <p>When I run this I get an exception:</p> <p>Run-time error '3011': The Microsoft Jet database engine could not find the object "Allowance1#txt'. Make sure the object exists and that you spell its name and the path name correctly.</p> <p>If I debug at this point, TableName is 'Allowance1', as expected.</p> <p>I guess my UnicodeTilde export specification is table specific, so I can't use it for multiple tables.</p> <p>What is the solution? Should I use something else, other than TransferText, or perhaps create the export specification programatically?</p> <p>Any help appreciated.</p>
[ { "answer_id": 161017, "author": "Richard A", "author_id": 24355, "author_profile": "https://Stackoverflow.com/users/24355", "pm_score": 0, "selected": false, "text": "ColNameHeader = True\nCharacterSet = Unicode\nFormat = Delimited(~)\n" }, { "answer_id": 172881, "author": "...
2008/10/02
[ "https://Stackoverflow.com/questions/160532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24355/" ]
160,534
<p>I need to get the "td" element of a table. I do not have the ability to add a mouseover or onclick event to the "td" element, so I need to add them with JQUERY.</p> <p>I need JQUERY to add the mouseover and onclick event to the all "td" elements in the table.</p> <p>Thats what I need, maybe someone can help me out? </p>
[ { "answer_id": 160547, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 6, "selected": true, "text": "$(function() {\n $(\"table#mytable td\").mouseover(function() {\n //The onmouseover code\n }).click(function...
2008/10/02
[ "https://Stackoverflow.com/questions/160534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7644/" ]
160,550
<p>I thought people would be working on little code projects together, but I don't see them, so here's an easy one:</p> <p>Code that validates a valid US Zip Code. I know there are ZIP code databases out there, but there are still uses, like web pages, quick validation, and also the fact that zip codes keep getting issued, so you might want to use weak validation.</p> <p>I wrote a little bit about zip codes in a side project on my wiki/blog:</p> <p><a href="https://benc.fogbugz.com/default.asp?W24" rel="nofollow noreferrer">https://benc.fogbugz.com/default.asp?W24</a></p> <p>There is also a new, weird type of zip code. </p> <p><a href="https://benc.fogbugz.com/default.asp?W42" rel="nofollow noreferrer">https://benc.fogbugz.com/default.asp?W42</a></p> <p>I can do the javascript code, but it would be interesting to see how many languages we can get here.</p>
[ { "answer_id": 160583, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 7, "selected": true, "text": "/(^\\d{5}$)|(^\\d{5}-\\d{4}$)/" }, { "answer_id": 160880, "author": "Mike Henry", "author_id": 14934, "a...
2008/10/02
[ "https://Stackoverflow.com/questions/160550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2910/" ]
160,555
<p>Here's the situation: I'm developing a simple application with the following structure:</p> <ul> <li>FormMain (startup point)</li> <li>FormNotification</li> <li>CompleFunctions</li> </ul> <p>Right?</p> <p>Well, in <strong>FormMain</strong> I have the following function:</p> <pre><code>private void DoItInNewThread(ParameterizedThreadStart pParameterizedThreadStart, object pParameters, ThreadPriority pThreadPriority) { Thread oThread = new Thread(pParameterizedThreadStart); oThread.CurrentUICulture = Settings.Instance.Language; oThread.IsBackground = true; oThread.Priority = pThreadPriority; oThread.Name = "μRemote: Background operation"; oThread.Start(pParameters); } </code></pre> <p>So, everytime that I need to call a time consuming method located on <strong>ComplexFunctions</strong> I do the following:</p> <pre><code>// This is FormMain.cs string strSomeParameter = "lala"; DoItInNewThread(new ParameterizedThreadStart(ComplexFunctions.DoSomething), strSomeParameter, ThreadPriority.Normal); </code></pre> <p>The other class, FormNotification, its a Form that display some information of the process to the user. This FormNotification could be called from FormMain or ComplexFunctions. Example:</p> <pre><code>// This is ComplexFunctions.cs public void DoSomething(string pSomeParameter) { // Imagine some time consuming task FormNotification formNotif = new FormNotification(); formNotif.Notify(); } </code></pre> <p>FormNotify has a timer, so, after 10 seconds closes the form. I'm not using formNotif.ShowDialog because I don't want to give focus to this Form. You could check <a href="https://stackoverflow.com/questions/156046/show-a-form-without-stealing-focus-in-c">this link</a> to see what I'm doing in Notify.</p> <p>Ok, here's the problem: When I call <strong>FormNotify</strong> from <strong>ComplexFunction</strong> which is called from another Thread in <strong>FormMain</strong> ... this <strong>FormNotify</strong> disappears after a few milliseconds. It's the same effect that when you do something like this:</p> <pre><code>using(FormSomething formSomething = new FormSomething) { formSomething.Show(); } </code></pre> <p><strong>How can avoid this?</strong></p> <p>These are possible solutions that I don't want to use:</p> <ul> <li>Using Thread.Sleep(10000) in FormNotify</li> <li>Using FormNotif.ShowDialog()</li> </ul> <p>This is a simplified scenario (FormNotify does some other fancy stuff that just stay for 10 seconds, but they are irrelevant to see the problem).</p> <p>Thanks for your time!!! And please, sorry my english.</p>
[ { "answer_id": 3712806, "author": "Andranik", "author_id": 447778, "author_profile": "https://Stackoverflow.com/users/447778", "pm_score": 0, "selected": false, "text": "Form1" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4386/" ]
160,557
<p>I have a Selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day). </p> <pre><code>select validity_Y label=2008 select validity_M label=08 select validity_D label=08 </code></pre> <p>This part gets repeated a lot throughout the test case. I'd like to reduce it by defining my custom action "selectValidity", so that I can have less redundancy, something like</p> <pre><code>selectValidity 2008,08,08 </code></pre> <p>What is the best (easiest, cleanest) way to add macros or subroutines to a test case?</p>
[ { "answer_id": 3712806, "author": "Andranik", "author_id": 447778, "author_profile": "https://Stackoverflow.com/users/447778", "pm_score": 0, "selected": false, "text": "Form1" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14955/" ]
160,587
<p>I'm using <code>Console.WriteLine()</code> from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what might be going on here?</p> <p>I can reproduce it by creating a WPF application in VS 2008, and simply adding <code>Console.WriteLine(&quot;text&quot;)</code> anywhere where it gets executed. Any ideas?</p> <p>All I need for right now is something as simple as <code>Console.WriteLine()</code>. I realize I could use log4net or somet other logging solution, but I really don't need that much functionality for this application.</p> <p><strong>Edit:</strong> I should have remembered that <code>Console.WriteLine()</code> is for console applications. Oh well, no stupid questions, right? :-) I'll just use <code>System.Diagnostics.Trace.WriteLine()</code> and DebugView for now.</p>
[ { "answer_id": 160606, "author": "Phobis", "author_id": 19854, "author_profile": "https://Stackoverflow.com/users/19854", "pm_score": 8, "selected": false, "text": "Trace.WriteLine(\"text\");\n" }, { "answer_id": 718505, "author": "John Leidegren", "author_id": 58961, ...
2008/10/02
[ "https://Stackoverflow.com/questions/160587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18505/" ]
160,604
<p>I'm trying to combine a list of functions like so.</p> <p>I have this:</p> <pre><code>Func&lt;int, bool&gt;[] criteria = new Func&lt;int, bool&gt;[3]; criteria[0] = i =&gt; i % 2 == 0; criteria[1] = i =&gt; i % 3 == 0; criteria[2] = i =&gt; i % 5 == 0; </code></pre> <p>And I want this:</p> <pre><code>Func&lt;int, bool&gt;[] predicates = new Func&lt;int, bool&gt;[3]; predicates[0] = i =&gt; i % 2 == 0; predicates[1] = i =&gt; i % 2 == 0 &amp;&amp; i % 3 == 0; predicates[2] = i =&gt; i % 2 == 0 &amp;&amp; i % 3 == 0 &amp;&amp; i % 5 == 0; </code></pre> <p>So far I've got the following code:</p> <pre><code>Expression&lt;Func&lt;int, bool&gt;&gt;[] results = new Expression&lt;Func&lt;int, bool&gt;&gt;[criteria.Length]; for (int i = 0; i &lt; criteria.Length; i++) { results[i] = f =&gt; true; for (int j = 0; j &lt;= i; j++) { Expression&lt;Func&lt;int, bool&gt;&gt; expr = b =&gt; criteria[j](b); var invokedExpr = Expression.Invoke( expr, results[i].Parameters.Cast&lt;Expression&gt;()); results[i] = Expression.Lambda&lt;Func&lt;int, bool&gt;&gt;( Expression.And(results[i].Body, invokedExpr), results[i].Parameters); } } var predicates = results.Select(e =&gt; e.Compile()).ToArray(); Console.WriteLine(predicates[0](6)); // Returns true Console.WriteLine(predicates[1](6)); // Returns false Console.WriteLine(predicates[2](6)); // Throws an IndexOutOfRangeException </code></pre> <p>Does anyone know what I'm doing wrong?</p>
[ { "answer_id": 160661, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 3, "selected": true, "text": "Func<int, bool>[] criteria = new Func<int, bool>[3]; \ncriteria[0] = i => i % 2 == 0; \ncriteria[1] = i => i % 3 == 0; \ncrit...
2008/10/02
[ "https://Stackoverflow.com/questions/160604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3820/" ]
160,608
<p>I've been wondering whether there is a good &quot;git export&quot; solution that creates a copy of a tree without the <code>.git</code> repository directory. There are at least three methods I know of:</p> <ol> <li><code>git clone</code> followed by removing the <code>.git</code> repository directory.</li> <li><a href="http://www.kernel.org/pub/software/scm/git/docs/git-checkout-index.html" rel="noreferrer"><code>git checkout-index</code></a> alludes to this functionality but starts with &quot;Just read the desired tree into the index...&quot; which I'm not entirely sure how to do.</li> <li><a href="http://code.google.com/p/git-export/" rel="noreferrer"><code>git-export</code></a> is a third-party script that essentially does a <code>git clone</code> into a temporary location followed by <code>rsync --exclude='.git'</code> into the final destination.</li> </ol> <p>None of these solutions really strike me as being satisfactory. The closest one to <code>svn export</code> might be option 1, because both require the target directory to be empty first. But option 2 seems even better, assuming I can figure out what it means to read a tree into the index.</p>
[ { "answer_id": 160620, "author": "jperras", "author_id": 5570, "author_profile": "https://Stackoverflow.com/users/5570", "pm_score": 5, "selected": false, "text": "$ git checkout-index --prefix=git-export-dir/ -a" }, { "answer_id": 160719, "author": "Greg Hewgill", "autho...
2008/10/02
[ "https://Stackoverflow.com/questions/160608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893/" ]
160,611
<p>I'm trying to unit test (JUnit) a DAO i've created. I'm using Spring as my framework, my DAO (JdbcPackageDAO) extends SimpleJdbcDaoSupport. The testing class (JdbcPackageDAOTest) extends AbstractTransactionalDataSourceSpringContextTests. I've overridden the configLocations as follows:</p> <pre><code>protected String[] getConfigLocations(){ return new String[] {"classpath:company/dc/test-context.xml"}; } </code></pre> <p>My test-context.xml file is defined as follows:</p> <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt; &lt;bean id="dataPackageDao" class="company.data.dao.JdbcPackageDAO"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;/bean&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="org.hsqldb.jdbcDriver"/&gt; &lt;property name="url" value="jdbc:hsqldb:hsql://localhost"/&gt; &lt;property name="username" value="sa" /&gt; &lt;property name="password" value="" /&gt; &lt;/bean&gt; &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="locations"&gt; &lt;list&gt; &lt;value&gt;company/data/dao/jdbc.properties&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>I'm using HSQL as my backend, it's running in standalone mode. My IDE of choice is eclipse. When I run the class as a JUnit test here's my error (below). I have no clue as to why its happening. hsql.jar is on my build path according to Eclipse.</p> <pre> org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: No suitable driver found for jdbc:hsqldb:hsql://localhost at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:219) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377) at org.springframework.test.AbstractTransactionalSpringContextTests.startNewTransaction(AbstractTransactionalSpringContextTests.java:387) at org.springframework.test.AbstractTransactionalSpringContextTests.onSetUp(AbstractTransactionalSpringContextTests.java:217) at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:101) at junit.framework.TestCase.runBare(TestCase.java:128) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.sql.SQLException: No suitable driver found for jdbc:hsqldb:hsql://localhost at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:291) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:277) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:259) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:241) at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:182) ... 18 more </pre>
[ { "answer_id": 160627, "author": "Max Stewart", "author_id": 18338, "author_profile": "https://Stackoverflow.com/users/18338", "pm_score": 2, "selected": false, "text": "jdbc:hsqldb:hsql://serverName:port/DBname\n" }, { "answer_id": 161220, "author": "NR.", "author_id": 1...
2008/10/02
[ "https://Stackoverflow.com/questions/160611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17337/" ]
160,614
<p>I have a Dynamic Data website built in Visual Studio 2008 using .NET 3.5 SP1. The site works OK on my Vista machine, but I get the following error when running it on a Windows XP machine:</p> <blockquote> <p>Server Error in '/FlixManagerWeb' Application. -------------------------------------------------------------------------------- The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. </p> <p>Requested URL: /FlixManagerWeb -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053</p> </blockquote> <p>I have added the .* -> aspnet_isapi.dll mapping in the site config, made sure that it is an "application," but that did not help. Anyone have any luck running a Dynamic Data website on Windows XP? What (if anything) special is required to get it to work?</p>
[ { "answer_id": 160627, "author": "Max Stewart", "author_id": 18338, "author_profile": "https://Stackoverflow.com/users/18338", "pm_score": 2, "selected": false, "text": "jdbc:hsqldb:hsql://serverName:port/DBname\n" }, { "answer_id": 161220, "author": "NR.", "author_id": 1...
2008/10/02
[ "https://Stackoverflow.com/questions/160614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2762/" ]
160,633
<p>Why are flat text files the state of the art for representing source code?</p> <p>Sure - the preprocessor and compiler need to see a flat file representation of the file, but that's easily created.</p> <p>It seems to me that some form of XML or binary data could represent lots of ideas that are very difficult to track, otherwise.</p> <p>For instance, you could embed UML diagrams right into your code. They could be generated semi-automatically, and annotated by the developers to highlight important aspects of the design. Interaction diagrams in particular. Heck, embedding any user drawing might make things more clear.</p> <p>Another idea is to embed comments from code reviews right into the code.</p> <p>There could be all sorts of aids to make merging multiple branches easier.</p> <p>Something I'm passionate about is not just tracking code coverage, but also looking at the parts of code covered by an automated test. The hard part is keeping track of that code, even as the source is modified. For instance, moving a function from one file to another, etc. This can be done with GUIDs, but they're rather intrusive to embed right in the text file. In a rich file format, they could be automatic and unobtrusive.</p> <p>So why are there no IDEs (to my knowledge, anyway) which allow you to work with code in this way?</p> <p><strong>EDIT:</strong> On October 7th, 2009.</p> <p>Most of you got very hung up on the word "binary" in my question. I retract it. Picture XML, very minimally marking up your code. The instant before you hand it to your normal preprocessor or compiler, you strip out all of the XML markup, and pass on just the source code. In this form, you could still do all of the normal things to the file: diff, merge, edit, work with in a simple and minimal editor, feed them into thousands of tools. Yes, the diff, merge, and edit, directly with the minimal XML markup, does get a tad more complicated. But I think the value could be enormous.</p> <p>If an IDE existed which respected all of the XML, you could add so much more than what we can do today.</p> <p>For instance, your DOxygen comments could actually <em>look</em> like the final DOxygen output.</p> <p>When someone wanted to do a code review, like Code Collaborator, they could mark up the source code, in place.</p> <p>The XML could even be hidden behind comments.</p> <pre><code>// &lt;comment author="mcruikshank" date="2009-10-07"&gt; // Please refactor to Delegate. // &lt;/comment&gt; </code></pre> <p>And then if you want to use vi or emacs, you can just skip over the comments.</p> <p>If I want to use a state-of-the-art editor, I can see that in about a dozen different helpful ways.</p> <p>So, that's my rough idea. It's not "building blocks" of pictures that you drag on the screen... I'm not that nuts. :)</p>
[ { "answer_id": 1535445, "author": "Rebol Tutorial", "author_id": 2687173, "author_profile": "https://Stackoverflow.com/users/2687173", "pm_score": 0, "selected": false, "text": "In pursuing (interests of) software\n developers,'' says Alsop, Asymetrix\n " } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8643/" ]
160,650
<p>Is there a way to run some custom Javascript whenever a client-side ASP.NET validator (<code>RequiredFieldValidator</code>, <code>RangeValidator</code>, etc) is triggered? </p> <p>Basically, I have a complicated layout that requires I run a custom script whenever a DOM element is shown or hidden. I'm looking for a way to automatically run this script when a validator is displayed. (I'm using validators with <code>Display="dynamic"</code>)</p>
[ { "answer_id": 160844, "author": "Leon Tayson", "author_id": 18413, "author_profile": "https://Stackoverflow.com/users/18413", "pm_score": 0, "selected": false, "text": "function customValidation()\n{\n Page_ClientValidate();\n if(!Page_IsValid)\n { //run your resize script }\n}...
2008/10/02
[ "https://Stackoverflow.com/questions/160650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23632/" ]
160,651
<p>I would like to provide downloadable files to website users, but want to hide the URL of the files from the user... I'm thinking an HTTPHandler could do the trick, but is it possible to retrieve a file from an external server and stream it to the user?</p> <p>Perhaps somebody can give me a hint at how to accomplish this, or point me to a resource where it's been done before?</p> <hr> <p>Just to elaborate on what I'm trying to achieve... I'm building an ASP.NET website, which contains a music download link. I want to protect the actual URLs of the file, and I also want to store them on an external (PHP) server (MUCH MUCH cheaper)... </p> <p>So what I need to do is set up a stream that can grab the file from a URL (points to another server), and stream it to the Response object without the user realising it's coming from another server.</p> <p>Will the TransmitFile method allow streaming of a file from a completely separate server? I don't want the file to be streamed "through" my server, as that defeats the purpose (saving bandwidth)... I want the client (browser) to download the file direct from the other server.</p> <p>Do I need a handler on the file hosting server perhaps? Maybe a PHP script on the other end is the way to go...?</p>
[ { "answer_id": 160690, "author": "Carlton Jenke", "author_id": 1215, "author_profile": "https://Stackoverflow.com/users/1215", "pm_score": 0, "selected": false, "text": "public class ZipDownloadModule: IHttpHandler, ICompressFilesView, IErrorView \n{\n CompressFilesPresenter _presente...
2008/10/02
[ "https://Stackoverflow.com/questions/160651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21969/" ]
160,666
<p>I'd like to have an HTML page which displays a single PNG or JPEG image. I want the image to take up the whole screen but when I do this:</p> <pre><code>&lt;img src=&quot;whatever.jpeg&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt; </code></pre> <p>It just stretches the image and messes up the aspect ratio. How do I solve this so the image has the correct aspect ratio while scaling to the maximum size possible ?</p> <hr /> <p>The solution posted by Wayne <strong>almost</strong> works except for the case where you have a tall image and a wide window. This code is a slight modification of his code which does what I want:</p> <pre class="lang-html prettyprint-override"><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function resizeToMax(id){ myImage = new Image() var img = document.getElementById(id); myImage.src = img.src; if(myImage.width / document.body.clientWidth &gt; myImage.height / document.body.clientHeight){ img.style.width = &quot;100%&quot;; } else { img.style.height = &quot;100%&quot;; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;img id=&quot;image&quot; src=&quot;test.gif&quot; onload=&quot;resizeToMax(this.id)&quot;&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 160674, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 2, "selected": false, "text": "<img src=\"whatever.jpeg\" width=\"100%\" height=\"auto\" />\n" }, { "answer_id": 160717, "author": "Wayn...
2008/10/02
[ "https://Stackoverflow.com/questions/160666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324/" ]
160,691
<p>How do you know if the HTTP compression setup is working? Is there any tool I can use to see the compressed page before it is uncompressed by the browser? Are there any tools to measure the amount compressed and response speed?</p>
[ { "answer_id": 18152731, "author": "bcattle", "author_id": 1161906, "author_profile": "https://Stackoverflow.com/users/1161906", "pm_score": 4, "selected": false, "text": "curl -H 'Accept-Encoding: gzip,deflate' -D - http://example.com\n" }, { "answer_id": 62414849, "author":...
2008/10/02
[ "https://Stackoverflow.com/questions/160691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17071/" ]
160,694
<p>What Javascript libraries can you recommend for syntax highlighting &lt;code&gt; blocks in HTML?</p> <p>(One suggestion per answer please).</p>
[ { "answer_id": 160768, "author": "Edu Felipe", "author_id": 21648, "author_profile": "https://Stackoverflow.com/users/21648", "pm_score": 3, "selected": false, "text": "$(\"code\").chili();\n" }, { "answer_id": 3359393, "author": "balupton", "author_id": 130638, "auth...
2008/10/02
[ "https://Stackoverflow.com/questions/160694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17453/" ]
160,697
<p>I personally like the <em>exclusive or</em>, <code>^</code>, operator when it makes sense in the context of boolean checks because of its conciseness. I much prefer to write</p> <pre><code>if (boolean1 ^ boolean2) { //do it } </code></pre> <p>than</p> <pre><code>if((boolean1 &amp;&amp; !boolean2) || (boolean2 &amp;&amp; !boolean1)) { //do it } </code></pre> <p>but I often get confused looks from other experienced Java developers (not just the newbies), and sometimes comments about how it should only be used for bitwise operations. </p> <p>I'm curious as to the best practices regarding the usage of the <code>^</code> operator.</p>
[ { "answer_id": 160700, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 9, "selected": true, "text": "!=" }, { "answer_id": 160701, "author": "Dre", "author_id": 23033, "author_profile": "https://Stackoverflow...
2008/10/02
[ "https://Stackoverflow.com/questions/160697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17123/" ]
160,724
<p>I'm working on a Google App Engine project. </p> <p>My app is working and looking correct locally, but when I try to upload images in an image directory, they're not being displayed at appspot.</p> <p>As a little troubleshoot, I put a HTML page in "/images/page2.html" and I can load that page at the appspot, but my pages don't display my images. So, it's not a problem with my path.</p> <p>As another sanity check, I'm also uploading a style sheet directory with .css code in it, and that's being read properly. </p> <p>I have a suspicion that the problem lies in my app.yaml file. </p> <p>Any ideas? </p> <p>I don't want to paste all the code here, but here are some of the key lines. The first two work fine. The third does not work: </p> <pre><code>&lt;link type="text/css" rel="stylesheet" href="/stylesheets/style.css" /&gt; &lt;a href="/images/Page2.html"&gt;Page 2&lt;/a&gt; &lt;img src="/images/img.gif"&gt; </code></pre> <p>This is my app.yaml file</p> <pre><code>application: myApp version: 1 runtime: python api_version: 1 handlers: - url: /stylesheets static_dir: stylesheets - url: /images static_dir: images - url: /.* script: helloworld.py </code></pre>
[ { "answer_id": 211073, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<img src=\"/images/img.gif\">\n" }, { "answer_id": 275705, "author": "Sarp Centel", "author_id": 16622, "a...
2008/10/02
[ "https://Stackoverflow.com/questions/160724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1179/" ]
160,726
<p>I have been thinking a lot about unit testing and how to improve the readability of the unit tests. I thought why not give a character to the classes in the unit test to clarify what they do. </p> <p>Here is a simple unit test that I wrote: </p> <pre><code>[TestFixture] public class when_dave_transfers_money_from_wamu_account_to_the_woodforest_account { [Test] public void should_increase_the_amount_in_woodforest_account_when_transaction_successfull() { Dave dave = new Dave(); Wamu wamu = new Wamu(); wamu.Balance = 150; wamu.AddUser(dave); Woodforest woodforest = new Woodforest(); woodforest.AddUser(dave); FundTransferService.Transfer(100, wamu, woodforest); Assert.AreEqual(wamu.Balance, 50); Assert.AreEqual(woodforest.Balance, 100); } } </code></pre> <p>Here is the Dave class: </p> <pre><code>/// &lt;summary&gt; /// This is Dave! /// &lt;/summary&gt; public class Dave : User { public Dave() { FirstName = "Dave"; LastName = "Allen"; } } </code></pre> <p>The unit test name clearly serves the purpose. But, maybe I want to dig a little deeper and assign the Wamu and Woodforest accounts to Dave whenever Dave is created. The problem is that it will move away from readability as I will have to use index values to refer to the account. </p> <p>What are your thoughts on making this more readable? </p>
[ { "answer_id": 160738, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 2, "selected": false, "text": "private Dave GetDave_With_Wamu_And_Woodforest_AccountsHookedUp()\n" }, { "answer_id": 160743, "author": "azamsharp...
2008/10/02
[ "https://Stackoverflow.com/questions/160726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3797/" ]
160,737
<p>I would like to create a Crystal Reports report using pre-existing LINQ classes that live in a different project than where the report lives. I can't find a way to do this. I'm using VS2008.</p> <p>Whenever I expand the "Project Data" tree, I see only classes in my current project. The "History" tree shows me the last 5 class in the OTHER project, but I need more than those 5. I found the "Make New Connection" option under "ADO.NET", but it looks like it's looking for XML sources and DLLs.</p>
[ { "answer_id": 160738, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 2, "selected": false, "text": "private Dave GetDave_With_Wamu_And_Woodforest_AccountsHookedUp()\n" }, { "answer_id": 160743, "author": "azamsharp...
2008/10/02
[ "https://Stackoverflow.com/questions/160737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
160,742
<p>I'm trying to generate some code at runtime where I put in some boiler-plate stuff and the user is allowed to enter the actual working code. My boiler-plate code looks something like this:</p> <pre><code>using System; public class ClassName { public double TheFunction(double input) { // user entered code here } } </code></pre> <p>Ideally, I think I want to use string.Format to insert the user code and create a unique class name, but I get an exception on the format string unless it looks like this:</p> <pre><code>string formatString = @" using System; public class ClassName {0} public double TheFunction(double input) {0} {2} {1} {1}"; </code></pre> <p>Then I call string.Format like this:</p> <pre><code>string entireClass = string.Format(formatString, "{", "}", userInput); </code></pre> <p>This is fine and I can deal with the ugliness of using {0} and {1} in the format string in place of my curly braces except that now my user input cannot use curly braces either. Is there a way to either escape the curly braces in my format string, or a good way to turn the curly braces in the user code into {0}'s and {1}'s?</p> <p>BTW, I know that this kind of thing is a security problem waiting to happen, but this is a Windows Forms app that's for internal use on systems that are not connected to the net so the risk is acceptable in this situation.</p>
[ { "answer_id": 160747, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 6, "selected": true, "text": "string s = String.Format(\"{{ hello to all }}\");\nConsole.WriteLine(s); //prints '{ hello to all }'\n" }, { "a...
2008/10/02
[ "https://Stackoverflow.com/questions/160742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4797/" ]
160,776
<p>For my server app, I need to check if an ip address is in our blacklist. </p> <p>What is the most efficient way of comparing ip addresses? Would converting the IP address to integer and comparing them efficient?</p>
[ { "answer_id": 160794, "author": "Mark Glorie", "author_id": 952, "author_profile": "https://Stackoverflow.com/users/952", "pm_score": 2, "selected": false, "text": "Sort()" }, { "answer_id": 61115899, "author": "gsaandy", "author_id": 1419876, "author_profile": "http...
2008/10/02
[ "https://Stackoverflow.com/questions/160776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599/" ]
160,791
<p>Maybe this is a dumb question, but I have the following behavior in Visual Studio 2005 while designing forms:</p> <p>1 - Drop a control onto the form (suppose it's a Label, just for discussion)</p> <p>2 - Drag that label to a specific location (aligning w/other controls, whatever)</p> <p>3 - Release the mouse button</p> <p>4 - The control is still stuck to the mouse!!!</p> <p>To get it un-stuck from the mouse, I have to hit ESC, which restores the Label to it's original location.</p> <p>This is driving me nuts. I literally have to use the arrow keys to move each control into place, pixel-by-pixel. I don't observe this behavior anywhere else in VS2005, nor do I observe it in the OS in general.</p> <p>I am running on Windows XP inside a Parallels Virtual Machine, hosted on OS X. I don't think there is a driver problem though, b/c as I already said, no other apps demonstrate anything like this.</p> <p>Please tell me there is some tiny checkbox buried somewhere that will turn off this behavior.</p>
[ { "answer_id": 160794, "author": "Mark Glorie", "author_id": 952, "author_profile": "https://Stackoverflow.com/users/952", "pm_score": 2, "selected": false, "text": "Sort()" }, { "answer_id": 61115899, "author": "gsaandy", "author_id": 1419876, "author_profile": "http...
2008/10/02
[ "https://Stackoverflow.com/questions/160791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
160,813
<p>I have a few 'helper' style extension methods I use quite regularly now <em>(they are mostly quite simple, intuitive, and work for good not evil, so please don't have this descend into a discussion around whether or not I should use them).</em> They are largely extending core .NET CLR classes.</p> <p>Currently, I have to copy the 'ExtensionMethods.cs' file that holds my extension methods to each new project within a solution to be able to use them in multiple projects.</p> <p>Is it possible to define an extension to work over multiple projects within a solution, or wrap them in an 'extensions' dll, or are they confined to the scope of project?</p> <p><strong>EDIT</strong> Whilst the 'dedicated project' answers are perfectly valid, I chose marxidad's as I prefer the approach he gives. Thanks for all the answers so far, and I have upmodded them all, as they were all good answers</p>
[ { "answer_id": 15844040, "author": "Csaba Toth", "author_id": 292502, "author_profile": "https://Stackoverflow.com/users/292502", "pm_score": 0, "selected": false, "text": "ObservableCollection" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
160,834
<p>I am a member of a team that is about to launch a beta of a python (Django specifically) based web site and accompanying suite of backend tools. The team itself has doubled in size from 2 to 4 over the past few weeks and we expect continued growth for the next couple of months at least. One issue that has started to plague us is getting everyone up to speed in terms of getting their development environment configured and having all the right eggs installed, etc.</p> <p>I'm looking for ways to simplify this process and make it less error prone. Both zc.buildout and virtualenv look like they would be good tools for addressing this problem but both seem to concentrate primarily on the python-specific issues. We have a couple of small subprojects in other languages (Java and Ruby specifically) as well as numerous python extensions that have to be compiled natively (lxml, MySQL drivers, etc). In fact, one of the biggest thorns in our side has been getting some of these extensions compiled against appropriate versions of the shared libraries so as to avoid segfaults, malloc errors and all sorts of similar issues. It doesn't help that out of 4 people we have 4 different development environments -- 1 leopard on ppc, 1 leopard on intel, 1 ubuntu and 1 windows.</p> <p>Ultimately what would be ideal would be something that works roughly like this, from the dos/unix prompt:</p> <p>$ git clone [repository url] ... $ python setup-env.py ...</p> <p>that then does what zc.buildout/virtualenv does (copy/symlink the python interpreter, provide a clean space to install eggs) then installs all required eggs, including installing any native shared library dependencies, installs the ruby project, the java project, etc.</p> <p>Obviously this would be useful for both getting development environments up as well as deploying on staging/production servers.</p> <p>Ideally I would like for the tool that accomplishes this to be written in/extensible via python, since that is (and always will be) the lingua franca of our team, but I am open to solutions in other languages.</p> <p>So, my question then is: does anyone have any suggestions for better alternatives or any experiences they can share using one of these solutions to handle larger/broader install bases?</p>
[ { "answer_id": 4060962, "author": "Brandon Rhodes", "author_id": 85360, "author_profile": "https://Stackoverflow.com/users/85360", "pm_score": 2, "selected": false, "text": "develop.py" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2168/" ]
160,848
<p>Does the compiler optimize out any multiplications by 1? That is, consider:</p> <pre><code>int a = 1; int b = 5 * a; </code></pre> <p>Will the expression 5 * a be optimized into just 5? If not, will it if a is defined as:</p> <pre><code>const int a = 1; </code></pre>
[ { "answer_id": 160850, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 5, "selected": true, "text": "const" }, { "answer_id": 160865, "author": "Community", "author_id": -1, "author_profile": "https://S...
2008/10/02
[ "https://Stackoverflow.com/questions/160848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16942/" ]
160,859
<p>I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs. A link to read about it would be great. A trivial explained example would be even better. Thank you.</p>
[ { "answer_id": 160884, "author": "Dan Lenski", "author_id": 20789, "author_profile": "https://Stackoverflow.com/users/20789", "pm_score": 1, "selected": false, "text": "a = dict(foo=\"bar\", zip=\"zap\", zig=\"zag\") # binds a to a newly-created dict object\nb = a # binds b to that same ...
2008/10/02
[ "https://Stackoverflow.com/questions/160859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15073/" ]
160,874
<p>I'm looking for software to create PNG8 format transparent images as per <a href="http://www.sitepoint.com/blogs/2007/09/18/png8-the-clear-winner/" rel="nofollow noreferrer">this article</a>.</p> <p><strong>NOTE:</strong> I need a Linux solution myself, but please submit answers for other OSes.</p>
[ { "answer_id": 342328, "author": "mercator", "author_id": 23263, "author_profile": "https://Stackoverflow.com/users/23263", "pm_score": 1, "selected": false, "text": "/c3" }, { "answer_id": 1143914, "author": "Ben Hardy", "author_id": 59441, "author_profile": "https:/...
2008/10/02
[ "https://Stackoverflow.com/questions/160874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/486/" ]
160,876
<p>I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails:</p> <pre><code>$s = new IO::Socket::INET( PeerAddr =&gt; 'stackoverflow.com', PeerPort =&gt; 80, Proto =&gt; 'tcp', ); die "Error: $!\n" unless $s; </code></pre> <p>I verified the following things:</p> <ul> <li><p>Perl is able to resolve addresses with gethostbyname (ie the code below works):</p> <p><code>my $ret = gethostbyname('stackoverflow.com'); print inet_ntoa($ret);</code></p></li> <li><p>The original source code works under Windows</p></li> <li>This is how it supposed to work (ie. it should resolve hostnames), since LWP tries to use this behavior (in fact I stumbled uppon the problem by trying to debug why LWP wasn't working for me)</li> <li>Running the script doesn't emit DNS requests (so it doesn't even try to resolve the name). Verified with Wireshark</li> </ul>
[ { "answer_id": 160907, "author": "oz10", "author_id": 14069, "author_profile": "https://Stackoverflow.com/users/14069", "pm_score": -1, "selected": false, "text": "use IO::Socket::INET;\n" }, { "answer_id": 160964, "author": "tye", "author_id": 21496, "author_profile"...
2008/10/02
[ "https://Stackoverflow.com/questions/160876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1265/" ]
160,881
<p>So this is a question for anyone who has had to integrate the building/compilation of legacy projects/code in a Team Build/MSBuild environment - specifically, Visual Basic 6 applications/projects.</p> <p><i>Outside</i> of writing a custom build Task (which I am not against) does anyone have any suggestions on how best to integrate compilation and versioning of legacy VB6 projects into MSBuild builds?</p> <p>I'm aware of the FreeToDev msbuild tasks at <a href="http://www.codeplex.com/freetodevtasks" rel="noreferrer">CodePlex</a> but they've been withdrawn at the moment.</p> <p>Ideally I'm looking to version and compile the code as well as capture the compilation output (especially errors) for the msbuild log.</p> <p>I've seen advice on encapsulating this functionality in a custom task, but really wondered if anyone has tried another solution (aside from executing shell commands) - In essence, does anyone have a "cleaner" solution?</p> <p>Ideally, executing commands using would be a last resort..</p>
[ { "answer_id": 160907, "author": "oz10", "author_id": 14069, "author_profile": "https://Stackoverflow.com/users/14069", "pm_score": -1, "selected": false, "text": "use IO::Socket::INET;\n" }, { "answer_id": 160964, "author": "tye", "author_id": 21496, "author_profile"...
2008/10/02
[ "https://Stackoverflow.com/questions/160881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18471/" ]
160,889
<p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p> <p>One example:</p> <p>I have to get all href tags, their corresponding text and some other text based on a different regex. So I have 3 expressions and would like to tokenize the line and extract tokens of text matching every expression.</p> <p>I have actually done this using flex (not to be confused with Adobe), which is an implementation of the good old lex. lex provides an elegant way to do this by executing "actions" based on expressions. One can control the way lex reading a file too (block / line based read).</p> <p>The problem is that flex actually produces C/ C++ code which actually does the tokenizing job. I have a make file which wraps all these things. I was wondering if perl /python can in some way do the same thing. Its just that I would like to do everything I like in a single programming language itself.</p> <p>Tokenizing is just one of the things that I want to do as part of my application.</p> <p>Apart from perl or python can any language (functional also) do this?</p> <p>I did read about PLY and ANTLR here (<a href="https://stackoverflow.com/questions/34081/parsing-where-can-i-learn-about-it#34085">Parsing, where can I learn about it</a>).</p> <p>But is there a way to do it naturally in python itself? pardon my ignorance, but are these tools used in any popular products / services?</p> <p>Thank you.</p>
[ { "answer_id": 160895, "author": "Swaroop C H", "author_id": 4869, "author_profile": "https://Stackoverflow.com/users/4869", "pm_score": 2, "selected": false, "text": "from pyparsing import Word, alphas\ngreet = Word( alphas ) + \",\" + Word( alphas ) + \"!\" # <-- grammar defined here\n...
2008/10/02
[ "https://Stackoverflow.com/questions/160889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24382/" ]
160,890
<p>I'm a Java head mainly, and I want a way to generate a pseudo-random number between 0 and 74. In Java I would use the method:</p> <pre><code>Random.nextInt(74) </code></pre> <p>I'm not interested in a discussion about seeds or true randomness, just how you accomplish the same task in Objective-C. I've scoured Google, and there just seems to be lots of different and conflicting bits of information.</p>
[ { "answer_id": 160910, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": false, "text": "#include <time.h>\n#include <stdlib.h>\n...\nsrand(time(NULL));\nint r = rand() % 74;\n" }, { "answer_id": 161141, ...
2008/10/02
[ "https://Stackoverflow.com/questions/160890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6044/" ]
160,904
<p>I have to write a component that re-creates SQL Server tables (structure and data) in an Oracle database. This component also has to take new data entered into the Oracle database and copy it back into SQL Server.</p> <p>Translating the data types from SQL Server to Oracle is not a problem. However, a critical difference between Oracle and SQL Server is causing a major headache. SQL Server considers a blank string ("") to be different from a <code>NULL</code> value, so a <code>char</code> column can be defined as <code>NOT NULL</code> and yet still include blank strings in the data.</p> <p>Oracle considers a blank string to be the same as a <code>NULL</code> value, so if a <code>char</code> column is defined as <code>NOT NULL</code>, you cannot insert a blank string. This is causing my component to break whenever a <code>NOT NULL</code> char column contains a blank string in the original SQL Server data.</p> <p>So far my solution has been to not use <code>NOT NULL</code> in any of my mirror Oracle table definitions, but I need a more robust solution. This has to be a code solution, so the answer can't be "use so-and-so's SQL2Oracle product".</p> <p>How would you solve this problem?</p> <p>Edit: here is the only solution I've come up with so far, and it may help to illustrate the problem. Because Oracle doesn't allow "" in a NOT NULL column, my component could intercept any such value coming from SQL Server and replace it with "@" (just for example).</p> <p>When I add a new record to my Oracle table, my code has to write "@" if I really want to insert a "", and when my code copies the new row back to SQL Server, it has to intercept the "@" and instead write "".</p> <p>I'm hoping there's a more elegant way.</p> <p>Edit 2: Is it possible that there's a simpler solution, like some setting in Oracle that gets it to treat blank strings the same as all the other major database? And would this setting also be available in Oracle Lite?</p>
[ { "answer_id": 160933, "author": "Camilo Díaz Repka", "author_id": 861, "author_profile": "https://Stackoverflow.com/users/861", "pm_score": 4, "selected": true, "text": "-> ' '" }, { "answer_id": 161001, "author": "Dr8k", "author_id": 6014, "author_profile": "https:/...
2008/10/02
[ "https://Stackoverflow.com/questions/160904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
160,905
<p>I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields.</p> <p>Here's my models.py:</p> <pre><code>class Tech(models.Model): name = models.CharField(max_length = 30) class Project(models.Model): title = models.CharField(max_length = 50) techs = models.ManyToManyField(Tech) </code></pre> <p>In other words, a Project can have different Tech objects and different tech objects can belong to different Projects (Project X was created with Python and Django, Project Y was C# and SQL Server)</p> <p>However, the admin site doesn't display any UI for the Tech objects. Here's my admin.py:</p> <pre><code>class TechInline(admin.TabularInline): model = Tech extra = 5 class ProjectAdmin(admin.ModelAdmin): fields = ['title'] inlines = [] list_display = ('title') admin.site.register(Project, ProjectAdmin) </code></pre> <p>I've tried adding the <code>TechInline</code> class to the <code>inlines</code> list, but that causes a </p> <pre><code>&lt;class 'home.projects.models.Tech'&gt; has no ForeignKey to &lt;class 'home.projects.models.Project'&gt; </code></pre> <p>Error. Also tried adding <code>techs</code> to the <code>fields</code> list, but that gives a </p> <blockquote> <p>no such table: projects_project_techs</p> </blockquote> <p>Error. I verified, and there is no <code>projects_project_techs</code> table, but there is a <code>projects_tech</code> one. Did something perhaps get screwed up in my syncdb? </p> <p>I am using Sqlite as my database if that helps.</p>
[ { "answer_id": 160916, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": true, "text": "TechInline" }, { "answer_id": 162932, "author": "swilliams", "author_id": 736, "author_profile": "h...
2008/10/02
[ "https://Stackoverflow.com/questions/160905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/736/" ]
160,923
<p>I am pretty sure I have seen this before, but I haven't found out / remembered how to do it. I want to have a line of code that when executed from the Delphi debugger I want the debugger to pop-up like there was a break point on that line. </p> <p>Something like:</p> <pre><code>FooBar := Foo(Bar); SimulateBreakPoint; // Cause break point to occur in Delphi IDE if attached WriteLn('Value: ' + FooBar); </code></pre> <p>Hopefully that makes sense. I know I could use an exception, but that would be a lot more overhead then I want. It is for some demonstration code.</p> <p>Thanks in advance!</p>
[ { "answer_id": 160993, "author": "Joeri Sebrechts", "author_id": 20980, "author_profile": "https://Stackoverflow.com/users/20980", "pm_score": 6, "selected": true, "text": "asm int 3 end;\n" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/255/" ]
160,924
<p>Sometimes when I try to start Firefox it says "a Firefox process is already running". So I have to do this:</p> <pre><code>jeremy@jeremy-desktop:~$ ps aux | grep firefox jeremy 7451 25.0 27.4 170536 65680 ? Sl 22:39 1:18 /usr/lib/firefox-3.0.1/firefox jeremy 7578 0.0 0.3 3004 768 pts/0 S+ 22:44 0:00 grep firefox jeremy@jeremy-desktop:~$ kill 7451 </code></pre> <p>What I'd like is a command that would do all that for me. It would take an input string and <code>grep</code> for it (or whatever) in the list of processes, and would kill all the processes in the output:</p> <pre><code>jeremy@jeremy-desktop:~$ killbyname firefox </code></pre> <p>I tried doing it in PHP but <code>exec('ps aux')</code> seems to only show processes that have been executed with <code>exec()</code> in the PHP script itself (so the only process it shows is itself.)</p>
[ { "answer_id": 160926, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 10, "selected": true, "text": "pkill firefox\n" }, { "answer_id": 160928, "author": "Bittercoder", "author_id": 4843, "author_profile": ...
2008/10/02
[ "https://Stackoverflow.com/questions/160924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
160,930
<p>How can I check if a given number is even or odd in C?</p>
[ { "answer_id": 160935, "author": "Chris Young", "author_id": 9417, "author_profile": "https://Stackoverflow.com/users/9417", "pm_score": 10, "selected": true, "text": "if (x % 2) { /* x is odd */ }\n" }, { "answer_id": 160936, "author": "Mark Cidade", "author_id": 1659, ...
2008/10/02
[ "https://Stackoverflow.com/questions/160930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24391/" ]
160,954
<p>I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database. </p> <p>database.yml looks like</p> <pre><code>development: adapter: postgresql database: blah blah ... oracle_db: adapter: oracle database: blah blah </code></pre> <p>My models which descend from data on the Oracle DB look something like </p> <pre><code>class LegacyDataClass &lt; ActiveRecord::Base establish_connection "oracle_db" set_primary_key :legacy_data_class_id has_one :other_legacy_class, :foreign key =&gt; :other_legacy_class_id_with_funny_column_name ... end </code></pre> <p>Now, by habit I often do a lot of my early development (and this is early development) by coding for a bit and then playing in the Rails console. For example, after defining all the associations for LegacyDataClass I'll start trying things like <code>a = LegacyDataClass.find(:first); puts a.some_association.name</code>. Unexpectedly, this dies with LegacyDataClass not being already loaded. </p> <p>I can then <code>require 'LegacyDataClass'</code> which fixes the problem until I either need to <code>reload!</code>, which won't actually reload it, or until I open a new instance of the console.</p> <p>Thus the questions:</p> <ul> <li><strong>Why</strong> does this happen? Clearly there is some Rails magic I am not understanding.</li> <li>What is the convenient Rails <strong>workaround</strong>?</li> </ul>
[ { "answer_id": 160989, "author": "James Baker", "author_id": 9365, "author_profile": "https://Stackoverflow.com/users/9365", "pm_score": 3, "selected": true, "text": "models/legacy_model.rb" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/160954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15046/" ]
160,960
<p>I have a function that takes a struct, and I'm trying to store its variables in array:</p> <pre><code>int detect_prm(Param prm) { int prm_arr[] = {prm.field1, prm.field2, prm.field3}; return 0; } </code></pre> <p>But with <code>gcc -Wall -ansi -pedantic-errors -Werror</code> I get the following error:</p> <blockquote> <p>initializer element is not computable at load time</p> </blockquote> <p>It looks fine to me, what's wrong?</p>
[ { "answer_id": 160969, "author": "Mike Thompson", "author_id": 2754, "author_profile": "https://Stackoverflow.com/users/2754", "pm_score": 5, "selected": true, "text": "int prm_arr[3];\n\nprm_arr[0] = prm.field1;\nprm_arr[1] = prm.field2;\nprm_arr[2] = prm.field3;\n" }, { "answer...
2008/10/02
[ "https://Stackoverflow.com/questions/160960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628/" ]
160,970
<p>If I have two variables:</p> <pre><code>Object obj; String methodName = "getName"; </code></pre> <p>Without knowing the class of <code>obj</code>, how can I call the method identified by <code>methodName</code> on it?</p> <p>The method being called has no parameters, and a <code>String</code> return value. It's <em>a getter for a Java bean</em>.</p>
[ { "answer_id": 160976, "author": "Owen", "author_id": 11442, "author_profile": "https://Stackoverflow.com/users/11442", "pm_score": 8, "selected": false, "text": "Class<?> c = Class.forName(\"class name\");\nMethod method = c.getDeclaredMethod(\"method name\", parameterTypes);\nmethod.in...
2008/10/02
[ "https://Stackoverflow.com/questions/160970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340/" ]
160,971
<p>I've read some of the recent language vs. language questions with interest... <a href="https://stackoverflow.com/questions/150043/python-v-perl#150103">Perl vs. Python</a>, <a href="https://stackoverflow.com/questions/136977/after-c-python-or-java#137343">Python vs. Java</a>, <a href="https://stackoverflow.com/questions/157207/can-one-language-be-better-than-another">Can one language be better than another?</a></p> <p>One thing I've noticed is that a lot of us have <em>very superficial</em> reasons for disliking languages. We notice these things at first glance and they turn us off. We shun what are probably perfectly good languages as a result of features that we'd probably learn to love or ignore in 2 seconds if we bothered.</p> <p>Well, I'm as guilty as the next guy, if not more. Here goes:</p> <ul> <li>Ruby: All the Ruby example code I see uses the <code>puts</code> command, and that's a sort of childish Yiddish anatomical term. So as a result, I can't take Ruby code seriously even though I should.</li> <li>Python: The first time I saw it, I smirked at the whole significant whitespace thing. I avoided it for the next several years. Now I hardly use anything else.</li> <li>Java: I don't like identifiersThatLookLikeThis. I'm not sure why exactly.</li> <li>Lisp: I have trouble with all the parentheses. Things of different importance and purpose (function declarations, variable assignments, etc.) are not syntactically differentiated and I'm too lazy to learn what's what.</li> <li>Fortran: uppercase everything hurts my eyes. I know modern code doesn't have to be written like that, but most example code is...</li> <li>Visual Basic: it bugs me that <code>Dim</code> is used to declare variables, since I remember the good ol' days of GW-BASIC when it was <em>only</em> used to dimension arrays.</li> </ul> <p>What languages <em>did</em> look right to me at first glance? Perl, C, QBasic, JavaScript, assembly language, BASH shell, FORTH.</p> <p>Okay, now that I've aired my dirty laundry... I want to hear yours. <strong>What are your language hangups? What superficial features bother you? How have you gotten over them?</strong></p>
[ { "answer_id": 160996, "author": "Michael Petrotta", "author_id": 23897, "author_profile": "https://Stackoverflow.com/users/23897", "pm_score": 3, "selected": false, "text": "throws" }, { "answer_id": 160997, "author": "LeopardSkinPillBoxHat", "author_id": 22489, "aut...
2008/10/02
[ "https://Stackoverflow.com/questions/160971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20789/" ]
160,974
<p>Basically I have the following class:</p> <pre><code>class StateMachine { ... StateMethod stateA(); StateMethod stateB(); ... }; </code></pre> <p>The methods stateA() and stateB() should be able return pointers to stateA() and stateB(). How to typedef the StateMethod?</p>
[ { "answer_id": 161000, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 2, "selected": false, "text": "class X\n{\n public:\n typedef const boost::function0<Method> Method;\n\n // some kind of mutually recursive...
2008/10/02
[ "https://Stackoverflow.com/questions/160974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1692070/" ]
160,995
<p>I tried this XAML:</p> <pre><code>&lt;Slider Width="250" Height="25" Minimum="0" Maximum="1" MouseLeftButtonDown="slider_MouseLeftButtonDown" MouseLeftButtonUp="slider_MouseLeftButtonUp" /&gt; </code></pre> <p>And this C#:</p> <pre><code>private void slider_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { sliderMouseDown = true; } private void slider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { sliderMouseDown = false; } </code></pre> <p>The sliderMouseDown variable never changes because the MouseLeftButtonDown and MouseLeftButtonUp events are never raised. How can I get this code to work when a user has the left mouse button down on a slider to have a bool value set to true, and when the mouse is up, the bool is set to false?</p>
[ { "answer_id": 168928, "author": "cplotts", "author_id": 22294, "author_profile": "https://Stackoverflow.com/users/22294", "pm_score": 4, "selected": false, "text": "this.AddHandler\n(\n Slider.MouseLeftButtonDownEvent,\n new MouseButtonEventHandler(slider_MouseLeftButtonDown),\n ...
2008/10/02
[ "https://Stackoverflow.com/questions/160995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23939/" ]
161,022
<p>I have some styles applied to html for example </p> <pre><code>&lt;body style="background: #C3DAF9;"&gt; </code></pre> <p>and when I use forms authentication it is ignored. If I put the style into an external .css file then it works. </p> <p>This doesn't seem like normal behaviour to me. </p>
[ { "answer_id": 161501, "author": "Errico Malatesta", "author_id": 24439, "author_profile": "https://Stackoverflow.com/users/24439", "pm_score": -1, "selected": false, "text": "<body bgcolor=\"#C3DAF9\">\n" }, { "answer_id": 165385, "author": "Stephen Price", "author_id": ...
2008/10/02
[ "https://Stackoverflow.com/questions/161022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24395/" ]
161,027
<p>Let's say I am modelling a process that involves a conversation or exchnage between two actors. For this example, I'll use something easily understandable:-</p> <ol> <li>Supplier creates a price list,</li> <li>Buyer chooses some items to buy and sends a Purchase Order,</li> <li>Supplier receives the purchase order and sends the goods.</li> <li>Supplier sends an invoice</li> <li>Buyer receives the invoice and makes a payment</li> </ol> <p>Of course each of those steps in itself could be quick complicated. How would you split this up into use cases in your requirements document?</p> <p>If this process was treated as a single use-case it could fill a book.</p> <p>Alternatively, making a use case out of each of the above steps would hide some of the essential interaction and flow that should be captured. Would it make sense to have a use case that starts at "Received a purchase order" and finishes at "Send an Invoice" and then another that starts at "Receive an Invoice" and ends at "Makes a Payment"?</p> <p>Any advice?</p>
[ { "answer_id": 161501, "author": "Errico Malatesta", "author_id": 24439, "author_profile": "https://Stackoverflow.com/users/24439", "pm_score": -1, "selected": false, "text": "<body bgcolor=\"#C3DAF9\">\n" }, { "answer_id": 165385, "author": "Stephen Price", "author_id": ...
2008/10/02
[ "https://Stackoverflow.com/questions/161027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14663/" ]
161,030
<p>In .NET is there a way to enable Assembly.Load tracing? I know while running under the debugger it gives you a nice message like "Loaded 'assembly X'" but I want to get a log of the assembly loads of my running application outside the debugger, preferably intermingled with my Debug/Trace log messages. </p> <p>I'm tracing out various things in my application and I basically want to know what action triggered a particular assembly to be loaded.</p>
[ { "answer_id": 161035, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 5, "selected": true, "text": "AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(OnAssemblyLoad);\n" }, { "answer_id": 15788...
2008/10/02
[ "https://Stackoverflow.com/questions/161030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12784/" ]
161,048
<p>I am trying to send an email from a site I am building, but it ends up in the yahoo spam folder. It is the email that sends credentials. What can I do to legitimize it?</p> <pre><code>$header = "From: site &lt;sales@site.com&gt;\r\n"; $header .= "To: $name &lt;$email&gt;\r\n"; $header .= "Subject: $subject\r\n"; $header .= "Reply-To: site &lt;sales@site.com&gt;" . "\r\n"; $header .= "MIME-VERSION: 1.0\r\n"; $header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $phpversion = phpversion(); $header .= "X-Mailer: PHP v$phpversion\r\n"; mail($email,$subject,$body,$header); </code></pre>
[ { "answer_id": 2194725, "author": "jschrab", "author_id": 12694, "author_profile": "https://Stackoverflow.com/users/12694", "pm_score": 2, "selected": false, "text": "mail('recipient@domain.com', 'Subject', $mail_body, $headers, \" -f sender@domain.com\");\n" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/161048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3800/" ]
161,053
<p>This question may sound fairly elementary, but this is a debate I had with another developer I work with.</p> <p>I was taking care to stack allocate things where I could, instead of heap allocating them. He was talking to me and watching over my shoulder and commented that it wasn't necessary because they are the same performance wise.</p> <p>I was always under the impression that growing the stack was constant time, and heap allocation's performance depended on the current complexity of the heap for both allocation (finding a hole of the proper size) and de-allocating (collapsing holes to reduce fragmentation, as many standard library implementations take time to do this during deletes if I am not mistaken).</p> <p>This strikes me as something that would probably be very compiler dependent. For this project in particular I am using a <a href="http://en.wikipedia.org/wiki/Metrowerks" rel="noreferrer">Metrowerks</a> compiler for the <a href="http://en.wikipedia.org/wiki/PowerPC" rel="noreferrer">PPC</a> architecture. Insight on this combination would be most helpful, but in general, for GCC, and MSVC++, what is the case? Is heap allocation not as high performing as stack allocation? Is there no difference? Or are the differences so minute it becomes pointless micro-optimization.</p>
[ { "answer_id": 161073, "author": "Dan Lenski", "author_id": 20789, "author_profile": "https://Stackoverflow.com/users/20789", "pm_score": 7, "selected": false, "text": "sub esp, 0x10\n" }, { "answer_id": 163765, "author": "Max Lybbert", "author_id": 10593, "author_pro...
2008/10/02
[ "https://Stackoverflow.com/questions/161053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366/" ]
161,056
<p>Is there a CSS editor which automatically expands one-line declarations as multi-line declarations on focus ? To clarify my thought, see example below:</p> <p>Original CSS:</p> <pre><code>div#main { color: orange; margin: 1em 0; border: 1px solid black; } </code></pre> <p>But when focusing on it, editor automatically expands it to:</p> <pre><code>div#main { color: orange; margin: 1em 0; border: 1px solid black; } </code></pre> <p>And when it looses focus, editor again it automatically compresses it to one-line declaration.</p> <p>Thanks.</p>
[ { "answer_id": 162432, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 0, "selected": false, "text": "function ExpandContractCSS()\n local ext = string.lower(props[\"FileExt\"])\n if ext ~= \"css\" then return end\n local ...
2008/10/02
[ "https://Stackoverflow.com/questions/161056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
161,064
<p>I'm running autoconf and configure sets SHELL to '/bin/sh'. This creates huge problems. How to force SHELL to be '/bin/bash' for autoconf?</p> <p>I'm trying to get this running on osx, it's working on linux. Linux is using SHELL=/bin/bash. osx defaults to /bin/sh.</p>
[ { "answer_id": 161070, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": -1, "selected": false, "text": "ln -f /bin/bash /bin/sh" }, { "answer_id": 161071, "author": "T Percival", "author_id": 954, "author_pr...
2008/10/02
[ "https://Stackoverflow.com/questions/161064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15054/" ]
161,074
<p>Currently running Server 2003 but am looking at reinstalling in the near future due to a change of direction with the domains. Should I take this opportunity to install Windows Server 2008 instead? I would love to play with new technology and the server is only for a small home business so downtime/performance issues aren't really a concern.</p>
[ { "answer_id": 161780, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 0, "selected": false, "text": "/3GB" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/161074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23988/" ]
161,084
<p>I was just wondering if anyone knew of a good way that I could parse the file at the bottom of the post.</p> <p>I have a database setup with the correct tables for each section eg Refferal Table,Caller Table,Location Table. Each table has the same columns that are show in the file below</p> <p>I would really like something that is fairly genetic so if the file layout changes it won't mess me around to much. At the moment I am just reading the file in a line at a time and just using a case statement to check which section i'm in. </p> <p>Is anyone able to help me with this?</p> <p>PS. I am using VB but C# or anything else will be fine, also the x's in the document are just personal info I have blanked</p> <p>Thanks, Nathan</p> <p>File:---></p> <pre><code>DIAL BEFORE YOU DIG Call 1100, Fax 1300 652 077 PO Box 7710 MELBOURNE, VIC 8004 Utilities are requested to respond within 2 working days and reference the Sequence number. [REFFERAL DETAILS] FROM= Dial Before You Dig - Web TO= Technical Services UTILITY ID= xxxxxx COMPANY= {Company Name} ENQUIRY DATE= 02/10/2008 13:53 COMMENCEMENT DATE= 06/10/2008 SEQUENCE NO= xxxxxxxxx PLANNING= No [CALLER DETAILS] CUSTOMER ID= 403552 CONTACT NAME= {Name of Contact} CONTACT HOURS= 0 COMPANY= Underground Utility Locating ADDRESS= {Address} SUBURB= {Suburb} STATE= {State} POSTCODE= 4350 TELEPHONE= xxxxxxxxxx MOBILE= xxxxxxxxxx FAX TYPE= Private FAX NUMBER= xxxxxxxxxx PUBLIC ADDRESS= xxxxxxxxxx PUBLIC TELEPHONE= EMAIL ADDRESS= {Email Address} [LOCATION DETAILS] ADDRESS= {Location Address} SUBURB= {Location Suburb} STATE= xxx POSTCODE= xxx DEPOSITED PLAN NO= 0 SECTION &amp; HUNDRED NO= 0 PROPERTY PHONE NO= SIDE OF STREET= B INTERSECTION= xxxxxx DISTANCE= 0-200m B ACTIVITY CODE= 15 ACTIVITY DESCRIPTION= xxxxxxxxxxxxxxxxxx MAP TYPE= StateGrid MAP REF= Q851_63 MAP PAGE= MAP GRID 1= MAP GRID 2= MAP GRID 3= MAP GRID 4= MAP GRID 5= GPS X COORD= GPS Y COORD= PRIVATE/ROAD/BOTH= B TRAFFIC AFFECTED= No NOTIFICATION NO= 3082321 MESSAGE= entire intersection of Allora-Clifton rd , Hillside rd and merivale st MOCSMESSAGE= Digsafe generated referral Notice: Please DO NOT REPLY TO THIS EMAIL as it has been automatically generated and replies are not monitored. Should you wish to advise Dial Before You Dig of any issues with this enquiry, please Call 1100 (See attached file: 3082321_LLGDA94.GML) </code></pre>
[ { "answer_id": 161152, "author": "pbh101", "author_id": 1266, "author_profile": "https://Stackoverflow.com/users/1266", "pm_score": 2, "selected": false, "text": "split()" }, { "answer_id": 224550, "author": "Hafthor", "author_id": 4489, "author_profile": "https://Sta...
2008/10/02
[ "https://Stackoverflow.com/questions/161084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
161,093
<p>I have a table that looks like that:</p> <p><img src="https://i.stack.imgur.com/R0TIr.jpg" alt="alt text"></p> <p>The rows are sorted by CLNDR_DATE DESC.</p> <p>I need to find a CLNDR_DATE that corresponds to the highlighted row, in other words:<br> Find the topmost group of rows WHERE EFFECTIVE_DATE IS NOT NULL, and return the CLNR_DATE of a last row of that group.</p> <p>Normally I would open a cursor and cycle from top to bottom until I find a NULL in EFFECTIVE_DATE. Then I would know that the date I am looking for is CLNDR_DATE, obtained at the previous step.</p> <p>However, I wonder if the same can be achieved with a single SQL?</p>
[ { "answer_id": 161105, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 4, "selected": true, "text": "SELECT min(CLNDR_DATE) FROM [TABLE]\nWHERE (EFFECTIVE_DATE IS NOT NULL)\n AND (CLNDR_DATE > (\n SELECT max(CL...
2008/10/02
[ "https://Stackoverflow.com/questions/161093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10557/" ]
161,108
<p>I've been developing web applications for a while and i am quite comfortable with mySql, in fact as many do i use some form of SQL almost every day. I like the syntax and a have zero problems writing queries or optimizing my tables. I have enjoyed this mysql <a href="http://www.tmtm.org/en/mysql/ruby/" rel="nofollow noreferrer">api</a>.</p> <p>The thing that has been bugging me is Ruby on Rails uses ActiveRecord and migrates everything so you use functions to query the database. I suppose the idea being you "never have to look at SQL again". Maybe this isn't KISS (keep it simple stupid) but is the ActiveRecord interface really best? If so why? </p> <p>Is development without having to ever write a SQL statement healthy? What if you ever have to look something up that isn't already defined as a rails function? I know they have a function that allows me to do a custom query. I guess really i want to know what people think the advantages are of using ActiveRecord over mySQL and if anyone feels like me that maybe this would be for the rails community what the calculator was to the math community and some people might forget how to do long division.</p>
[ { "answer_id": 162267, "author": "François Beausoleil", "author_id": 7355, "author_profile": "https://Stackoverflow.com/users/7355", "pm_score": 3, "selected": true, "text": "Post.find(1)\n" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/161108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18159/" ]
161,123
<p>I want Netbeans 6.1 to store the .netbeans directory in another place than the default. How do I do this?</p>
[ { "answer_id": 161142, "author": "cretzel", "author_id": 18722, "author_profile": "https://Stackoverflow.com/users/18722", "pm_score": 0, "selected": false, "text": " <Netbeans>/etc/netbeans.conf\n\n netbeans_default_userdir=<dir>\n" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/161123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18722/" ]
161,127
<p>We have a scenario where we want to display a list of items and indicate which is the "current" item (with a little arrow marker or a changed background colour).</p> <p>ItemsControl is no good to us, because we need the context of "SelectedItem". However, we want to move the selection programattically and not allow the user to change it.</p> <p>Is there a simple way to make a ListBox non-interactive? We can fudge it by deliberately swallowing mouse and keyboard events, but am I missing some fundamental property (like setting "IsEnabled" to false without affecting its visual style) that gives us what we want?</p> <p>Or ... is there another WPF control that's the best of both worlds - an ItemsControl with a SelectedItem property?</p>
[ { "answer_id": 161232, "author": "Mark Glorie", "author_id": 952, "author_profile": "https://Stackoverflow.com/users/952", "pm_score": 1, "selected": false, "text": " <ItemsControl DataContext=\"{Binding Source={StaticResource Things}}\" ItemsSource=\"{Binding}\" Margin=\"0\">\n <Ite...
2008/10/02
[ "https://Stackoverflow.com/questions/161127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/615/" ]
161,166
<p>Currently I'm trying to erase a sequence of iterators from a set, however GCC's standard library seems to be broken because std::set::erase(iterator) should return the an iterator (next iterator), however in GCC it returns void (which is standard?)</p> <p>Anyways I want to write:</p> <pre><code>myIter = mySet.erase(myIter); </code></pre> <p>But GCC doesn't like it... So Is it safe to write this instead?</p> <pre><code>mySet.erase(myIter++); </code></pre> <p>Edit: And yes I'm checking against mySet.end();</p>
[ { "answer_id": 161239, "author": "Camille", "author_id": 16990, "author_profile": "https://Stackoverflow.com/users/16990", "pm_score": 4, "selected": true, "text": "mySet.erase(myIter++);\n" }, { "answer_id": 161254, "author": "PierreBdR", "author_id": 7136, "author_p...
2008/10/02
[ "https://Stackoverflow.com/questions/161166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
161,176
<p>I am working on an ASP site hosted using SUN One (used to be called Chillisoft) server. I am having trouble loading in an XML file, the code I am using is below</p> <pre><code>dim directory set directory = Server.CreateObject("MSXML2.DOMDocument") if(directory.load(Server.MapPath("directory.xml"))) then Response.Write("Loaded") else Response.Write("NotLoaded") If directory.parseError.errorCode Then Response.Write( "Parse error" ) end if end if </code></pre> <p>My asp page and directory.xml are both in the same folder "/public_html/".</p> <p>I think the problem might have something to do with the mappath not finding the file, but no errors are returned so not sure what to do.</p> <p>Thanks</p>
[ { "answer_id": 161245, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 1, "selected": false, "text": "Set directory = Server.CreateObject(\"MSXML2.DOMDocument\")\ndirectory.async = false\ndirectory.load(Server.MapPath(...
2008/10/02
[ "https://Stackoverflow.com/questions/161176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
161,177
<p>Does C++ support '<a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/finally.html" rel="noreferrer"><strong>finally</strong></a>' blocks?</p> <p>What is the <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="noreferrer"><strong>RAII idiom</strong></a>?</p> <p>What is the difference between C++'s RAII idiom and <a href="http://www.c-sharpcorner.com/uploadfile/dipalchoksi/usingstatement11092005065819am/usingstatement.aspx" rel="noreferrer"><strong>C#'s 'using' statement</strong></a>?</p>
[ { "answer_id": 161179, "author": "Kevin", "author_id": 6386, "author_profile": "https://Stackoverflow.com/users/6386", "pm_score": 8, "selected": false, "text": "// A class with implements RAII\nclass lock\n{\n mutex &m_;\n\npublic:\n lock(mutex &m)\n : m_(m)\n {\n m...
2008/10/02
[ "https://Stackoverflow.com/questions/161177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6386/" ]
161,200
<p>Is there a way to upload a file to a FTP server when behind an HTTP proxy ?</p> <p>It seems that uploading a file is not supported behind an HTTP Proxy using .Net Webclient. (<a href="http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.proxy.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.proxy.aspx</a>).</p> <p>If there is no workaround ? If not, do you know a good and free FTP library I can use ?</p> <p><strong>Edit</strong>: Unfortunately, I don't have any FTP proxy to connect to.</p>
[ { "answer_id": 161807, "author": "Alexander", "author_id": 16724, "author_profile": "https://Stackoverflow.com/users/16724", "pm_score": 3, "selected": false, "text": "FtpWebRequest" }, { "answer_id": 162321, "author": "Alexander", "author_id": 16724, "author_profile"...
2008/10/02
[ "https://Stackoverflow.com/questions/161200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22970/" ]
161,212
<p>I need to be able to periodically send email alerts to subscribed users. PHP seems to struggle with sending <em>one</em> message, so I'm looking for good alternatives.</p> <p>Any language will do, if the implementation is fast enough. The amount of mails sent will eventually be in the thousands.</p> <p>If purchasing licensed software can be avoided, so much the better.</p>
[ { "answer_id": 162087, "author": "jj33", "author_id": 430, "author_profile": "https://Stackoverflow.com/users/430", "pm_score": 1, "selected": false, "text": "MAIL FROM:<me@example.com>\nRCPT TO:<you@example.com>\nDATA\nFrom: Me <me@example.com>\nTo: You <you@example.com>\nSubject: test ...
2008/10/02
[ "https://Stackoverflow.com/questions/161212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21716/" ]
161,221
<p>I am using the System.Web.Routing assembly in a WebForms application. When running the application deployed on win2008/IIS7 I got the following message.</p> <blockquote> <p>Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration. </p> </blockquote> <p>This is only a problem when using a route I have configured. It is not a problem when directly navigating to an aspx page.</p> <p>EnableSessionState has been turned on in both the web.config and the Page directive. I have added the Session entry to httpmodule of the web.config.</p> <p>This is not an issue when developing using Visual Studio on my workstation. It is only a problem when trying to run the application under IIS7 on Win 2008.</p>
[ { "answer_id": 950695, "author": "SirDemon", "author_id": 80813, "author_profile": "https://Stackoverflow.com/users/80813", "pm_score": 1, "selected": false, "text": "IRouteHandler" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/161221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5360/" ]
161,222
<p>I've been using maven2 and hudson for a while to do my continuous integration, but I find that Eclipse and Maven do not play well together. Sure there's a plugin, but it's cranky to mash the maven project into something that eclipse likes and the build times and unit test are too long. I'm considering switching back to a pure eclipse project with no ant and no maven involved. With the infinitest plugin and possible the JavaRebel agent, it would give me a very fast build-deploy-test cycle. However I'd still like to have automatic and testing as well, so:</p> <p>How do I use continuous integration with an Eclipse project?</p> <p>Is there a command line way to do it? </p> <p>Is there a build server that already supports it natively?</p>
[ { "answer_id": 161476, "author": "Valters Vingolds", "author_id": 885, "author_profile": "https://Stackoverflow.com/users/885", "pm_score": 2, "selected": false, "text": "mvn -o verify -Ditest" }, { "answer_id": 229724, "author": "s3v1", "author_id": 17554, "author_pr...
2008/10/02
[ "https://Stackoverflow.com/questions/161222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17554/" ]
161,224
<p>Hibernate has a handful of methods that, one way or another, takes your object and puts it into the database. What are the differences between them, when to use which, and why isn't there just one intelligent method that knows when to use what?</p> <p>The methods that I have identified thus far are:</p> <ul> <li><code>save()</code></li> <li><code>update()</code></li> <li><code>saveOrUpdate()</code></li> <li><code>saveOrUpdateCopy()</code></li> <li><code>merge()</code></li> <li><code>persist()</code></li> </ul>
[ { "answer_id": 10100479, "author": "Hari Krishna", "author_id": 1325738, "author_profile": "https://Stackoverflow.com/users/1325738", "pm_score": 3, "selected": false, "text": "save()" }, { "answer_id": 17040611, "author": "HakunaMatata", "author_id": 1418801, "author...
2008/10/02
[ "https://Stackoverflow.com/questions/161224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2238/" ]
161,231
<p><strong>Is there a way of forcing a (child) class to have constructors with particular signatures or particular static methods in C# or Java?</strong></p> <p>You can't obviously use interfaces for this, and I know that it will have a limited usage. One instance in which I do find it useful is when you want to enforce some design guideline, for example:</p> <p><strong>Exceptions</strong><br> They should all have the four canonical constructors, but there is no way to enforce it. You have to rely on a tool like FxCop (C# case) to catch these.</p> <p><strong>Operators</strong><br> There is no contract that specifies that two classes can be summed (with operator+ in C#)</p> <p>Is there any design pattern to work around this limitation? What construct could be added to the <em>language</em> to overcome this limitation in future versions of C# or Java?</p>
[ { "answer_id": 161271, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 2, "selected": false, "text": "class Base\n{\n private Base() { }\n public Base(int x) {}\n}\n\nclass Derived : Base\n{\n //public Derived() { } won't com...
2008/10/02
[ "https://Stackoverflow.com/questions/161231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7028/" ]
161,238
<p>As I understand it, the command to ignore the <em>content</em> of a directory using SVN is this:</p> <pre><code>svn propset svn:ignore "*" tmp/ </code></pre> <p>This should set the ignore property on the content of the <code>tmp</code> directory, right? In other words, the wildcard is set to be the ignore value on the tmp directory. Trouble is, here's what is happening on my Windows box:</p> <pre><code>&gt; svn propset svn:ignore "*" ./tmp property 'svn:ignore' set on 'app' property 'svn:ignore' set on 'config' property 'svn:ignore' set on 'db' property 'svn:ignore' set on 'doc' property 'svn:ignore' set on 'lib' property 'svn:ignore' set on 'log' property 'svn:ignore' set on 'nbproject' property 'svn:ignore' set on 'public' [etc...] </code></pre> <p>That's not right. Am I doing something wrong (or perhaps going insane), or is my svn on Windows broken?</p> <p><strong>Some notes:</strong></p> <ul> <li>The machine is running Windows Vista SP1</li> <li>Setting this property via Tortoise works perfectly.</li> <li>I'm using the <a href="http://www.collab.net/downloads/subversion/" rel="nofollow noreferrer">Collabnet binaries for Windows</a>:</li> </ul> <blockquote> <p><code>> svn --version<br /> svn, version 1.5.2 (r32768)<br /> compiled Aug 28 2008, 19:05:34</code></p> </blockquote> <hr> <p><strong><em>Update:</em></strong> I've have just tried this on a Windows XP machine and it works as expected. So either this is a Vista specific issue, or there is a problem with my Vista configuration. Is anyone else able to reproduce this problem on Vista? I have just spotted that Vista isn't listed as one of the supported platforms on the <a href="http://www.collab.net/downloads/subversion/" rel="nofollow noreferrer">CollabNet downloads page</a>.</p>
[ { "answer_id": 161338, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 4, "selected": true, "text": "*" }, { "answer_id": 161380, "author": "Greg Hewgill", "author_id": 893, "author_profile": "h...
2008/10/02
[ "https://Stackoverflow.com/questions/161238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1944/" ]
161,251
<p>Is there a programming language suitable for building web applications, that is compiled, strongly-typed, and isn't ASP.NET?</p> <p>I thought of using Mono (<a href="http://www.mono-project.com/" rel="nofollow noreferrer">http://www.mono-project.com/</a>), but I wonder if there are any other alternatives.</p> <p>(If the language and framework are open-source, that's a big plus!)</p>
[ { "answer_id": 2465962, "author": "none", "author_id": 78244, "author_profile": "https://Stackoverflow.com/users/78244", "pm_score": 2, "selected": false, "text": "* A Web parameters module. This module takes care of retrieving the forms or URL parameters and to build an associative tabl...
2008/10/02
[ "https://Stackoverflow.com/questions/161251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23341/" ]
161,252
<p>I'm trying to run some commands in paralel, in background, using bash. Here's what I'm trying to do:</p> <pre><code>forloop { //this part is actually written in perl //call command sequence print `touch .file1.lock; cp bigfile1 /destination; rm .file1.lock;`; } </code></pre> <p>The part between backticks (``) spawns a new shell and executes the commands in succession. The thing is, control to the original program returns only after the last command has been executed. I would like to execute the whole statement in background (I'm not expecting any output/return values) and I would like the loop to continue running.</p> <p>The calling program (the one that has the loop) would not end until all the spawned shells finish.</p> <p>I could use threads in perl to spawn different threads which call different shells, but it seems an overkill...</p> <p>Can I start a shell, give it a set of commands and tell it to go to the background?</p>
[ { "answer_id": 161284, "author": "GavinCattell", "author_id": 21644, "author_profile": "https://Stackoverflow.com/users/21644", "pm_score": 4, "selected": false, "text": "for command in $commands\ndo\n \"$command\" &\ndone\nwait\n" }, { "answer_id": 161291, "author": "Zsol...
2008/10/02
[ "https://Stackoverflow.com/questions/161252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23780/" ]
161,315
<p>I wrote a small web app using ruby on rails, its main purpose is to upload, store, and display results from xml(files can be up to several MB) files. After running for about 2 months I noticed that the mongrel process was using about 4GB of memory. I did some research on debugging ruby memory leaks and could not find much. So I have two questions.</p> <ul> <li>Are there any good tools that can be used to find memory leaks in Ruby/rails?</li> <li>What type of coding patterns cause memory leaks in ruby?</li> </ul>
[ { "answer_id": 164206, "author": "Daniel Beardsley", "author_id": 13216, "author_profile": "https://Stackoverflow.com/users/13216", "pm_score": 4, "selected": false, "text": "#Put this in applictation_controller.rb\nbefore_filter :log_ram # or use after_filter\ndef log_ram\n logger.warn...
2008/10/02
[ "https://Stackoverflow.com/questions/161315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
161,342
<p>I need to validate the email address of my users. Unfortunately, making a validator that <a href="https://www.rfc-editor.org/rfc/rfc2822#section-3.4.1" rel="nofollow noreferrer">conforms to standards</a> is hard.</p> <p><a href="http://www.ex-parrot.com/%7Epdw/Mail-RFC822-Address.html" rel="nofollow noreferrer">Here</a> is an example of a regex expression that tries to conform to the standard.</p> <p>Is there a PHP library (preferably, open-source) that validates an email address?</p>
[ { "answer_id": 161362, "author": "Chris", "author_id": 4742, "author_profile": "https://Stackoverflow.com/users/4742", "pm_score": 4, "selected": false, "text": "filter_var($someEmail, FILTER_VALIDATE_EMAIL);" }, { "answer_id": 161909, "author": "Pierre Spring", "author_i...
2008/10/02
[ "https://Stackoverflow.com/questions/161342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1599/" ]
161,348
<p>Given the following:</p> <pre><code>#light //any function returning bool * 'a let foo = let x = ref 10 fun () -&gt; x := !x - 1 if !x &lt;&gt; 0 then (true, x) else (false, x) while let (c,x) = foo() in c do print_any x;//can't access x, but would be convinent. //this is how I want it to work, without all the typing let rec loop f = match f() with | (true, x) -&gt; print_any x loop f | (false, _) -&gt; () loop foo </code></pre> <p>How should I go about solving this? Or should I just go through the hassle to convert "foo" to a sequence expression?</p>
[ { "answer_id": 161362, "author": "Chris", "author_id": 4742, "author_profile": "https://Stackoverflow.com/users/4742", "pm_score": 4, "selected": false, "text": "filter_var($someEmail, FILTER_VALIDATE_EMAIL);" }, { "answer_id": 161909, "author": "Pierre Spring", "author_i...
2008/10/02
[ "https://Stackoverflow.com/questions/161348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21182/" ]
161,356
<p>How can I create a new Word document pro grammatically using Visual Studio Tools for Office? </p>
[ { "answer_id": 298600, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "Globals.ThisAddIn.Application.Documents.Add(ref objTemplate, ref missingType, ref missingType, ref missingType); \n" }, { ...
2008/10/02
[ "https://Stackoverflow.com/questions/161356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
161,368
<p>We're moving a solution with 20+ projects from .net 2.0 to 3.5 and at the same time moving from Visual Studio 2005 to 2008. We're also at the same time switching from MS Entlib 2.0 to 4.0. </p> <ul> <li>Is there any reasons not to let the Visual Studio wizard convert the solution for us?</li> <li>Is 3.5 fully backwards compatible with 2.0?</li> <li>Is Entlib 4.0 fully backwards compatible with 2.0?</li> </ul> <p><strong>Edit:</strong> I might been a bit confused when I wrote this, the backwards compatability is supposed to mean; is there anything that exists in a 2.0 project that will not work/compile in 3.5</p> <p>:)</p> <p>//W</p>
[ { "answer_id": 1048688, "author": "Christian Hayter", "author_id": 115413, "author_profile": "https://Stackoverflow.com/users/115413", "pm_score": 1, "selected": false, "text": "CacheManager cache = CacheFactory.GetCacheManager()" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/161368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2538222/" ]
161,378
<p>I have a WinForms TreeView with one main node and several sub-nodes.</p> <p>How can I hide the + (plus sign) in the main node?</p>
[ { "answer_id": 161401, "author": "Doug L.", "author_id": 19179, "author_profile": "https://Stackoverflow.com/users/19179", "pm_score": 5, "selected": true, "text": ".ShowRootLines = false" } ]
2008/10/02
[ "https://Stackoverflow.com/questions/161378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
161,388
<p>I'm using @media print in my external css file to hide menus etc. However while printing the little triangle of a dropdownlist still shows. Is there a css setting available to hide it as well and only print the selected item?</p>
[ { "answer_id": 161468, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 1, "selected": false, "text": "<select name=\"Snakes\" style=\"width: 200px;\">\n <option value=\"A\">Anaconda</option>\n <option value=\"B\">Boa</optio...
2008/10/02
[ "https://Stackoverflow.com/questions/161388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
161,398
<p>I'm possibly just stupid, but I'm trying to find a user in Active Directory from C#, using the Login name ("domain\user").</p> <p>My "Skeleton" AD Search Functionality looks like this usually:</p> <pre><code>de = new DirectoryEntry(string.Format("LDAP://{0}", ADSearchBase), null, null, AuthenticationTypes.Secure); ds = new DirectorySearcher(de); ds.SearchScope = SearchScope.Subtree; ds.PropertiesToLoad.Add("directReports"); ds.PageSize = 10; ds.ServerPageTimeLimit = TimeSpan.FromSeconds(2); SearchResult sr = ds.FindOne(); </code></pre> <p>Now, that works if I have the full DN of the user (ADSearchBase usually points to the "Our Users" OU in Active Directory), but I simply have no idea how to look for a user based on the "domain\user" syntax.</p> <p>Any Pointers?</p>
[ { "answer_id": 161719, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 4, "selected": true, "text": "String.Format(\"(&(objectCategory=person)(objectClass=user)(sn={0}))\", \n EscapeFilterLiteral(lastName, false)); ...
2008/10/02
[ "https://Stackoverflow.com/questions/161398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
161,399
<p>I have a control where I have to check in which page I am, so I can set a certain variable accordingly.</p> <pre><code>string pageName = this.Page.ToString(); switch (pageName) { case "ASP.foo_bar_aspx": doSomething(); break; default: doSomethingElse(); break; } </code></pre> <p>this works fine locally and on some developmentservers, however when I put it live, It stopped working because I don't get <code>ASP.foo_bar_aspx</code> but <code>_ASP.foo_bar_aspx</code> (notice the underscore in the live version) Why does it act that way, Can I set it somehow?</p>
[ { "answer_id": 161409, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 1, "selected": false, "text": "HttpContext.Current.Request.FilePath" }, { "answer_id": 161411, "author": "leppie", "author_id": 15541, "a...
2008/10/02
[ "https://Stackoverflow.com/questions/161399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15981/" ]
161,404
<p>I have three tables, A, B, C, where A is many to one B, and B is many to one C. I'd like a list of all C's in A. </p> <p>My tables are something like this: A[id, valueA, lookupB], B[id, valueB, lookupC], C[id, valueC]. I've written a query with two nested SELECTs, but I'm wondering if it's possible to do INNER JOIN with DISTINCT somehow.</p> <pre><code>SELECT valueC FROM C INNER JOIN ( SELECT DISTINCT lookupC FROM B INNER JOIN ( SELECT DISTINCT lookupB FROM A ) A2 ON B.id = A2.lookupB ) B2 ON C.id = B2.lookupC </code></pre> <p>EDIT: The tables are fairly large, A is 500k rows, B is 10k rows and C is 100 rows, so there are a lot of uneccesary info if I do a basic inner join and use DISTINCT in the end, like this:</p> <pre><code>SELECT DISTINCT valueC FROM C INNER JOIN B on C.id = B.lookupB INNER JOIN A on B.id = A.lookupB </code></pre> <p>This is very, very slow (magnitudes times slower than the nested SELECT I do above.</p>
[ { "answer_id": 161423, "author": "kristian", "author_id": 20377, "author_profile": "https://Stackoverflow.com/users/20377", "pm_score": 1, "selected": false, "text": "SELECT DISTINCT C.valueC\nFROM \nC\nINNER JOIN B ON C.id = B.lookupC\nINNER JOIN A ON B.id = A.lookupB\n" }, { "a...
2008/10/02
[ "https://Stackoverflow.com/questions/161404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2973/" ]
161,432
<p>Imagine the following type:</p> <pre><code>public struct Account { public int Id; public double Amount; } </code></pre> <p>What is the best algorithm to synchronize two <code>IList&lt;Account&gt;</code> in C# 2.0 ? (No linq) ?</p> <p>The first list (L1) is the reference list, the second (L2) is the one to synchronize according to the first:</p> <ul> <li>All accounts in L2 that are no longer present in L1 must be deleted from L2</li> <li>All accounts in L2 that still exist in L1 must be updated (amount attribute)</li> <li>All accounts that are in L1 but not yet in L2 must be added to L2</li> </ul> <p>The Id identifies accounts. It's no too hard to find a naive and working algorithm, but I would like to know if there is a smart solution to handle this scenario without ruining readability and perfs.</p> <p><strong>EDIT</strong> :</p> <ul> <li>Account type doesn't matter, is could be a class, has properties, equality members, etc.</li> <li>L1 and L2 are not sorted</li> <li>L2 items could not be replaced by L1 items, they must be updated (field by field, property by property)</li> </ul>
[ { "answer_id": 161535, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 2, "selected": false, "text": "class Program\n{\n static void Main()\n {\n List<string> left = new List<string> { \"Alice\", \"Charles...
2008/10/02
[ "https://Stackoverflow.com/questions/161432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4687/" ]
161,443
<p>In Kohana/CodeIgniter, I can have a URL in this form:</p> <pre><code>http://www.name.tld/controller_name/method_name/parameter_1/parameter_2/parameter_3 ... </code></pre> <p>And then read the parameters in my controller as follows:</p> <pre><code>class MyController { public function method_name($param_A, $param_B, $param_C ...) { // ... code } } </code></pre> <p>How do you achieve this in the Zend Framework?</p>
[ { "answer_id": 161636, "author": "Andrew Taylor", "author_id": 1776, "author_profile": "https://Stackoverflow.com/users/1776", "pm_score": 4, "selected": false, "text": "$router = new Zend_Controller_Router_Rewrite();\n\n$router->addRoute(\n 'index',\n new Zend_Controller_Router_Ro...
2008/10/02
[ "https://Stackoverflow.com/questions/161443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5742/" ]
161,462
<p>I'm using <code>org.w3c</code> <code>XML API</code> to open an existing <code>XML</code> file. I'm removing some nodes , and I'm adding others instead.</p> <p>The problem is that the new nodes that are added are written one after the other, with no newline and no indentation what so ever. While it's true that the <code>XML</code> file is valid , it is very hard for a human to examine it.</p> <p>Is there anyway to add indentation , or at least a newline after each node?</p>
[ { "answer_id": 161478, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 7, "selected": true, "text": "Transformer" }, { "answer_id": 10412619, "author": "Thilina", "author_id": 1369861, "author_profile": "ht...
2008/10/02
[ "https://Stackoverflow.com/questions/161462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11234/" ]
161,474
<p>My basic question is, in .NET, how do I clone WebControls?</p> <p>I would like to build a custom tag, which can produce multiple copies of its children. Ultimately I intend to build a tag similar to in JSP/Struts.</p> <p>But the first hurdle I have is the ability to duplicate/clone the contents of a control.</p> <p>Consider this rather contrived example;</p> <pre><code>&lt;custom:duplicate count="2"&gt; &lt;div&gt; &lt;p&gt;Some html&lt;/p&gt; &lt;asp:TextBox id="tb1" runat="server" /&gt; &lt;/div&gt; &lt;/custom:duplicate&gt; </code></pre> <p>The HTML markup which is output would be something like,</p> <pre><code>&lt;div&gt; &lt;p&gt;Some html&lt;/p&gt; &lt;input type="text" id="tb1" /&gt; &lt;/div&gt; &lt;div&gt; &lt;p&gt;Some html&lt;/p&gt; &lt;input type="text" id="tb1" /&gt; &lt;/div&gt; </code></pre> <p><em>Note: I know i have the id duplicated, I can come up with a solution to that later!</em></p> <p>So what we would have is my custom control with 3 children (I think) - a literal control, a TextBox control, and another literal control.</p> <p>In this example I have said 'count=2' so what the control should do is output/render its children twice.</p> <p>What I would hope to do is write some "OnInit" code which does something like:</p> <pre><code>List&lt;WebControl&gt; clones; for(int i=1; i&lt;count; i++) { foreach(WebControl c in Controls) { WebControl clone = c.Clone(); clones.Add(clone); } } Controls.AddRange(clones); </code></pre> <p>However, as far as I can tell, WebControls do not implement ICloneable, so its not possible to clone them in this way.</p> <p>Any ideas how I can clone WebControls?</p>
[ { "answer_id": 1372034, "author": "Juri", "author_id": 50109, "author_profile": "https://Stackoverflow.com/users/50109", "pm_score": 1, "selected": false, "text": "public class MyCustomServerCtrl\n{\n\n ...\n\n public MyCustomServerCtrl Clone()\n {\n return MemberwiseClone() a...
2008/10/02
[ "https://Stackoverflow.com/questions/161474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24232/" ]
161,477
<p>Is there a typedef equivalent in C#, or someway to get some sort of similar behaviour? I've done some googling, but everywhere I look seems to be negative. Currently I have a situation similar to the following:</p> <pre><code>class GenericClass&lt;T&gt; { public event EventHandler&lt;EventData&gt; MyEvent; public class EventData : EventArgs { /* snip */ } // ... snip } </code></pre> <p>Now, it doesn't take a rocket scientist to figure out that this can very quickly lead to a lot of typing (apologies for the horrible pun) when trying to implement a handler for that event. It'd end up being something like this:</p> <pre><code>GenericClass&lt;int&gt; gcInt = new GenericClass&lt;int&gt;; gcInt.MyEvent += new EventHandler&lt;GenericClass&lt;int&gt;.EventData&gt;(gcInt_MyEvent); // ... private void gcInt_MyEvent(object sender, GenericClass&lt;int&gt;.EventData e) { throw new NotImplementedException(); } </code></pre> <p>Except, in my case, I was already using a complex type, not just an int. It'd be nice if it were possible to simplify this a little...</p> <p>Edit: ie. perhaps typedefing the EventHandler instead of needing to redefine it to get similar behaviour.</p>
[ { "answer_id": 161484, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 10, "selected": true, "text": "using CustomerList = System.Collections.Generic.List<Customer>;\n" }, { "answer_id": 161488, "author": "Oreg...
2008/10/02
[ "https://Stackoverflow.com/questions/161477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]