qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
306,602
<p>I am porting an existing application to C# and want to improve performance wherever possible. Many existing loop counters and array references are defined as System.UInt32, instead of the Int32 I would have used.</p> <p>Is there any significant performance difference for using UInt32 vs Int32?</p>
[ { "answer_id": 306670, "author": "Rohan West", "author_id": 38686, "author_profile": "https://Stackoverflow.com/users/38686", "pm_score": 0, "selected": false, "text": " Console.WriteLine(Int32.MaxValue); // Max interation 2147483647\n Console.WriteLine(UInt32.MaxValue...
2008/11/20
[ "https://Stackoverflow.com/questions/306602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12113/" ]
306,626
<p>I'm completely stumped on this one. I have three different lists that need to be displayed on the screen. It's completely possible that the lists will extend past the bottom edge of the screen, so I would need scrolling.</p> <p>I've tried using a <code>ScrollView</code> with a <code>LinearLayout</code> child, and putting my <code>ListViews</code> in the <code>LinearView</code>, but all of the <code>ListViews</code> lock to a fixed height with scroll bars. Using other kinds of Layouts means no scrolling.</p> <p>Does anyone have any suggestions, or will I need to programmatically add the list items to some layout and hope for the best?</p>
[ { "answer_id": 5127111, "author": "hgllnt", "author_id": 593529, "author_profile": "https://Stackoverflow.com/users/593529", "pm_score": 3, "selected": false, "text": "ListAdapter listAdapter = listView.getAdapter();\n \nint rows = listAdapter.getCount() / columns;\nint height = 60 * ...
2008/11/20
[ "https://Stackoverflow.com/questions/306626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12096/" ]
306,641
<p>I am implementing a validation class in classic ASP. How should the validation class interface with my other classes? </p> <p>My current setup: The User class's set methods call the appropriate validation method in the validation class. Any errors that occur are stored in User.mError. For example, here's my set method for the Email member variable in ASP Classic:</p> <pre><code>Class User Property Let Email(EmailInput) If (myValidation.isEmail(EmailInput)) then mEmail = EmailInput Else mError = "Invalid Email Address format." End If </code></pre> <p>I don't like how I'm going to need an error member variable for every object that calls my validation class. Suggestions on a better setup?</p> <p>Any suggestions for a validation architecture I should review as a benchmark?</p>
[ { "answer_id": 306823, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "\nPsuedo Code.\n\nclass EmailValidator\n...\nfunction Validate(byval EmailAddress as string, optional byval Result as ...
2008/11/20
[ "https://Stackoverflow.com/questions/306641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26180/" ]
306,642
<p>How can I retrieve raw time-series data from a Proficy Historian/iHistorian?</p> <p>Ideally, I would ask for data for a particular tag between two dates.</p>
[ { "answer_id": 306646, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 2, "selected": false, "text": "<add name=\"HistorianConnectionString\" \n providerName=\"ihOLEDB.iHistorian.1\" \n connectionString=\"\n Pr...
2008/11/20
[ "https://Stackoverflow.com/questions/306642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29/" ]
306,668
<p>I've been preaching both to my colleagues and here on SO about the goodness of using parameters in SQL queries, especially in .NET applications. I've even gone so far as to promise them as giving immunity against SQL injection attacks.</p> <p>But I'm starting to wonder if this really is true. Are there any known SQL injection attacks that will be successfull against a parameterized query? Can you for example send a string that causes a buffer overflow on the server?</p> <p>There are of course other considerations to make to ensure that a web application is safe (like sanitizing user input and all that stuff) but now I am thinking of SQL injections. I'm especially interested in attacks against MsSQL 2005 and 2008 since they are my primary databases, but all databases are interesting. </p> <p>Edit: To clarify what I mean by parameters and parameterized queries. By using parameters I mean using "variables" instead of building the sql query in a string.<br> So instead of doing this: </p> <pre><code>SELECT * FROM Table WHERE Name = 'a name' </code></pre> <p>We do this:</p> <pre><code>SELECT * FROM Table WHERE Name = @Name </code></pre> <p>and then set the value of the @Name parameter on the query / command object.</p>
[ { "answer_id": 306675, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 7, "selected": true, "text": "security_level" }, { "answer_id": 306676, "author": "Steven A. Lowe", "author_id": 9345, "author_...
2008/11/20
[ "https://Stackoverflow.com/questions/306668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30366/" ]
306,679
<p>If a line of text is wrapped to an additional line, how do I determine programmatically the point in the string where it was broken.</p> <p>Example: Input string = "This is a test of a wrapped line of text".</p> <pre><code> Based on the width of the richTextBox it could display: This is a test of a wrapped line of text. </code></pre> <p>What I need to determine is offset in the line of the word(s) that got wrapped. In the above case the word "text".</p> <p>When I extract the Xaml from the richTextBox, I get the original text unwrapped.</p> <p>Thanks,</p> <p>Bob Kerlinger</p>
[ { "answer_id": 313168, "author": "Mike Two", "author_id": 23659, "author_profile": "https://Stackoverflow.com/users/23659", "pm_score": 2, "selected": false, "text": "public partial class Window1 : Window\n{\n public Window1()\n {\n InitializeComponent();\n }\n\n priva...
2008/11/20
[ "https://Stackoverflow.com/questions/306679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37918/" ]
306,684
<p>I've encountered a weird situation:</p> <p>Messages are sent from ServerA to ServerB. It goes into ServerA outgoing queue and then sent to ServerB's queue.</p> <p>ServerB crashed. We had to reformat. When we brought it up, we forgot to install the MSMQ Service.</p> <p>Messages begin pilling up in ServerA's outgoing queue until the program that sends messages throws an insufficient resources exception.</p> <p>We notice the the error and installed the MSMQ Service onto ServerB. ServerA begins to immediately emptying its outgoing queue.</p> <p>When we started the program to process messages on ServerB, it couldn't connect. We learned that we forgot to create the queue on ServerB. However, by this time, it was too late. All 900K messages that sat in ServerA's queue has been sent to ServerB. From what I can tell, ServerB threw them away because it was not configured with the destination queue. I already know that the correct solution is to STOP the queue on ServerA until after we've completely setup ServerB.</p> <p>The question is: Is this really the true behavior that we should expect from MSMQ? I would've thought that a more defensive design approach would've been for ServerB to reject the messages instead of taking it and throwing them away.</p>
[ { "answer_id": 546587, "author": "Carlos A. Ibarra", "author_id": 37835, "author_profile": "https://Stackoverflow.com/users/37835", "pm_score": 3, "selected": true, "text": "MQ_SEND_ACCESS" }, { "answer_id": 18854569, "author": "barrypicker", "author_id": 415559, "aut...
2008/11/20
[ "https://Stackoverflow.com/questions/306684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13484/" ]
306,709
<p>I've been using SVN a lot as a single user on a single computer</p> <p>Now I'd like to share my stuff across multiple computers</p> <p>So far I've been checking out from <code>file://c:/myproject</code></p> <p>I'd like to checkout from <code>svn://mycomputer/myproject</code></p> <p>How can I map the first into the second?</p>
[ { "answer_id": 306834, "author": "localshred", "author_id": 29690, "author_profile": "https://Stackoverflow.com/users/29690", "pm_score": 2, "selected": false, "text": "svnserve -d -r /path/to/repos/\n" }, { "answer_id": 451002, "author": "Christian Studer", "author_id": ...
2008/11/20
[ "https://Stackoverflow.com/questions/306709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6367/" ]
306,713
<p>I'm having some trouble navigating Java's rule for inferring generic type parameters. Consider the following class, which has an optional list parameter:</p> <pre><code>import java.util.Collections; import java.util.List; public class Person { private String name; private List&lt;String&gt; nicknames; public Person(String name) { this(name, Collections.emptyList()); } public Person(String name, List&lt;String&gt; nicknames) { this.name = name; this.nicknames = nicknames; } } </code></pre> <p>My Java compiler gives the following error:</p> <pre><code>Person.java:9: The constructor Person(String, List&lt;Object&gt;) is undefined </code></pre> <p>But <code>Collections.emptyList()</code> returns type <code>&lt;T&gt; List&lt;T&gt;</code>, not <code>List&lt;Object&gt;</code>. Adding a cast doesn't help</p> <pre><code>public Person(String name) { this(name,(List&lt;String&gt;)Collections.emptyList()); } </code></pre> <p>yields</p> <pre><code>Person.java:9: inconvertible types </code></pre> <p>Using <code>EMPTY_LIST</code> instead of <code>emptyList()</code></p> <pre><code>public Person(String name) { this(name, Collections.EMPTY_LIST); } </code></pre> <p>yields</p> <pre><code>Person.java:9: warning: [unchecked] unchecked conversion </code></pre> <p>Whereas the following change makes the error go away:</p> <pre><code>public Person(String name) { this.name = name; this.nicknames = Collections.emptyList(); } </code></pre> <p>Can anyone explain what type-checking rule I'm running up against here, and the best way to work around it? In this example, the final code example is satisfactory, but with larger classes, I'd like to be able to write methods following this &quot;optional parameter&quot; pattern without duplicating code.</p> <p>For extra credit: when is it appropriate to use <code>EMPTY_LIST</code> as opposed to <code>emptyList()</code>?</p>
[ { "answer_id": 306748, "author": "carson", "author_id": 25343, "author_profile": "https://Stackoverflow.com/users/25343", "pm_score": 7, "selected": false, "text": "Collections.<String>emptyList();\n" }, { "answer_id": 306750, "author": "Dan Vinton", "author_id": 21849, ...
2008/11/20
[ "https://Stackoverflow.com/questions/306713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
306,722
<p>I have a table in my MYSQL database which does not have a primary key, but has a unique key on two columns. When using MyEclipse's Hibernate reverse engineer tool to create a mapping for that table, it generates two classes, one for named after the table itself, and one with an "Id" suffix. It seems most of the useful methods ended up in the Id class, so it seems that is the one you would instantiate and save to persist data. I can appreciate the fact that the Id class is created in order to represent a unique row in the table / mapped object, but what is the use of splitting out this into two classes, and what, then is the use of the non-Id-suffixed class?</p> <p>My colleague argues you can accomplish the same with just one class and scoffs at using the reverse engineering for these tables which don't have a primary key. I, on the other hand, assume MyEclipse developers are much smarter than me and that there is a really good reason to do it this way. Is there?</p>
[ { "answer_id": 306748, "author": "carson", "author_id": 25343, "author_profile": "https://Stackoverflow.com/users/25343", "pm_score": 7, "selected": false, "text": "Collections.<String>emptyList();\n" }, { "answer_id": 306750, "author": "Dan Vinton", "author_id": 21849, ...
2008/11/20
[ "https://Stackoverflow.com/questions/306722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
306,732
<p>I have a Freemarker template which contains a bunch of placeholders for which values are supplied when the template is processed. I want to conditionally include part of the template if the userName variable is supplied, something like:</p> <pre><code>[#if_exists userName] Hi ${userName}, How are you? [/#if_exists] </code></pre> <p>However, the FreeMarker manual seems to indicate that if_exists is deprecated, but I can't find another way to achieve this. Of course, I could simple providing an additional boolean variable isUserName and use that like this:</p> <pre><code>[#if isUserName] Hi ${userName}, How are you? [/#if] </code></pre> <p>But if there's a way of checking whether userName exists then I can avoid adding this extra variable.</p>
[ { "answer_id": 306749, "author": "Ulf Lindback", "author_id": 30354, "author_profile": "https://Stackoverflow.com/users/30354", "pm_score": 9, "selected": true, "text": "[#if userName??]\n Hi ${userName}, How are you?\n[/#if]\n" }, { "answer_id": 306766, "author": "Ulf Lind...
2008/11/20
[ "https://Stackoverflow.com/questions/306732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
306,743
<p>What is the most efficient way to detect duplicates in a 10 column / 50K row table? I'm using MSSQL 8.0</p>
[ { "answer_id": 306756, "author": "Guge", "author_id": 37771, "author_profile": "https://Stackoverflow.com/users/37771", "pm_score": 4, "selected": false, "text": "group by" }, { "answer_id": 306789, "author": "Aaron Palmer", "author_id": 24908, "author_profile": "http...
2008/11/20
[ "https://Stackoverflow.com/questions/306743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39426/" ]
306,757
<p><strong>Given:</strong> Constructing an ADO Connection object from one thread and giving it to another thread is <strong><em>forbidden</em></strong>. The two threads are different apartments, and even though the first thread will <strong>never</strong> touch it again (not even maintain a reference to it!), it doesn't matter. </p> <p>That ADO Connection object was created by ThreadA, ThreadA is the only thread, ever, under any circumstances, at all, ever, that is allowed to use that Connection object, ever.</p> <p>Now replace "ADO Connection" with "ADO.NET Connection". Does the same rule apply?</p> <hr> <p>i know that most objects in the .NET framework are not thread-safe. For example, the <a href="http://msdn.microsoft.com/en-us/library/system.collections.dictionaryentry.aspx" rel="nofollow noreferrer">DictionaryEntry</a> structure in the SDK says: </p> <blockquote> <p><strong>Thread Safety</strong><br> Any public <strong>static</strong> members of this type are thread safe. Any instance members are not guaranteed to be thread safe.</p> </blockquote> <p>i understand that <strong>not thread-safe</strong> means that i have to synchronize access to the object if i am going to access it from different threads. That's all well and good, and i could ensure only one thread access the object at a time:</p> <pre><code>lock (myObject) { ... } </code></pre> <p>But there's something more than not being thread-safe. </p> <p>In COM, (some) objects are bound to the "<em>apartment</em>" that created it. Once the object has been constructed on one apartment, you are <strong><em>forbidden</em></strong> from accessing it from another apartment - no matter how much you protect that object from multiple simultaneous thread access.</p> <p>Does a similar concept exist in .NET? </p> <hr> <h2>More Information</h2> <p>i know you are forbidden from accessing Controls from threads other than the one that created it - even if you use it in a thread-safe manner. This is not documented on MSDN:</p> <blockquote> <p><strong>Thread Safety</strong></p> <p>Only the following members are thread safe: BeginInvoke, EndInvoke, Invoke, InvokeRequired, and CreateGraphics if the handle for the control has already been created. Calling CreateGraphics before the control's handle has been created on a background thread can cause illegal cross thread calls.</p> </blockquote> <p>There is no mention of Controls throwing exceptions when you create and use them from a single thread - when that thread is not the first thread that was created when the application started.</p> <p>But what about arbitrary objects? What about:</p> <pre><code>public class MyClass { int _number; public int Number { get { return _number; } set { _number = value; } } } MyClass myObject = new MyClass(); </code></pre> <p>As long as i synchronize access to myObject two threads are allowed to talk to it?</p> <hr> <p>The same goes for:</p> <pre><code>List&lt;Object&gt; sharedList = new List&lt;Object&gt;(); </code></pre> <p>Two threads can talk to the list, as long as they don't do it simultaneously, usually with:</p> <pre><code>lock (sharedList) { sharedList.Add(data); } </code></pre> <p>are two threads allowed to touch the same object?</p> <hr> <p>The same goes for:</p> <pre><code>IAsyncResult ar = BeginSetLabelToTheValueINeed(label1); ... EndSetLabelToTheValueINeed(ar); </code></pre> <hr> <p>The same goes for:</p> <pre><code>//Fetch image on connection that is an existing DB transaction public static Bitmap GetImageThumbnail(DbConnection conn, int imageID) { } </code></pre> <p>being converted into the asynchronous delegate pattern:</p> <pre><code>//Begin fetching an image on connection that is an existing DB transaction IAsyncResult ar = BeginGetImageThumbnuts(conn, imageID, callback, stateOjbect); ... //Finish fetching an image on connection that is an existing DB transaction Bitmap thumb = EndGetImageNumbthail(ar); </code></pre> <hr> <p>Rather than answering the question, people went off on a discussion about design patterns in ADO.NET. Please answer the question. Ignore the examples if they confuse and distract your squirrel brains.</p>
[ { "answer_id": 483780, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 1, "selected": false, "text": "public class MyClass\n{\n int _number;\n\n public int Number { get { return _number; } set { _number = value; }...
2008/11/20
[ "https://Stackoverflow.com/questions/306757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
306,779
<p>I have a PPPOE connection on a computer. That computer has two LAN cards and I activated ICS on it. The problem is, the connection kinda degrades over time (don't know why), and a redial would be nice, hourly maybe. I was thinking of writing an AutoIT script that would do this, if, for example I'm sending some data to a port the gateway pc is listening on. The only trouble is, I don't know what's the name of the executable I would have to run.</p> <p>EDIT: I'm interested in the one with the GUI.</p> <p>EDIT 2: I am interested in automating this process, and wouldn't like to have to write the thing in AutoIT (this a last resort option).</p>
[ { "answer_id": 484495, "author": "sven", "author_id": 46, "author_profile": "https://Stackoverflow.com/users/46", "pm_score": 3, "selected": true, "text": "rasdial connectionname\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/306779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
306,788
<p>How do I check if the timestamp date of a record is before midnight today?</p> <p>datediff is driving me nuts...</p>
[ { "answer_id": 306794, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 3, "selected": false, "text": "WHERE dtColumn < DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))\n" }, { "answer_id": 306802, "author": "StingyJa...
2008/11/20
[ "https://Stackoverflow.com/questions/306788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/750/" ]
306,806
<p>I have the following entity class (in Groovy):</p> <pre><code>import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue import javax.persistence.GenerationType @Entity public class ServerNode { @Id @GeneratedValue(strategy = GenerationType.AUTO) Long id String firstName String lastName } </code></pre> <p>and my persistence.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"&gt; &lt;persistence-unit name="NewPersistenceUnit"&gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;properties&gt; &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/Icarus"/&gt; &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/&gt; &lt;property name="hibernate.connection.username" value="root"/&gt; &lt;property name="hibernate.connection.password" value=""/&gt; &lt;property name="hibernate.archive.autodetection" value="class"/&gt; &lt;property name="hibernate.show_sql" value="true"/&gt; &lt;property name="hibernate.format_sql" value="true"/&gt; &lt;property name="hbm2ddl.auto" value="create"/&gt; &lt;/properties&gt; &lt;class&gt;net.interaxia.icarus.data.models.ServerNode&lt;/class&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>and the script:</p> <pre><code>import javax.persistence.EntityManager import javax.persistence.EntityManagerFactory import javax.persistence.Persistence import net.interaxia.icarus.data.models.ServerNode def factory = Persistence.createEntityManagerFactory("NewPersistenceUnit") def manager = factory.createEntityManager() manager.getTransaction().begin() manager.persist new ServerNode(firstName: "Test", lastName: "Server") manager.getTransaction().commit() </code></pre> <p>the database <em>Icarus</em> exists, but currently has no tables. I would like Hibernate to automatically create and/or update the tables based on the entity classes. How would I accomplish this?</p>
[ { "answer_id": 306825, "author": "billjamesdev", "author_id": 13824, "author_profile": "https://Stackoverflow.com/users/13824", "pm_score": 6, "selected": false, "text": "<property name=\"hbm2ddl.auto\" value=\"create\"/>\n" }, { "answer_id": 306875, "author": "toolkit", ...
2008/11/20
[ "https://Stackoverflow.com/questions/306806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18811/" ]
306,839
<p>Is there a way to reuse a 3rd party control reference?</p> <p>For example, I have this referenced in my App.xaml</p> <pre><code>xmlns:cust="clr-namespace:ThirdParty.Controls;assembly=ThirdParty.Controls" </code></pre> <p>I don't want to repeat this 3rd party control xml namespace on each page/control that needs a control from the library. </p> <p>Is there anyway to centralize these references and use the prefix defined here? The possibility of each control having a different prefix is also worrisome. In asp.net you would put a reference in the web.config and it was available globally, I'm just looking to see if there is a similar method in WPF.</p>
[ { "answer_id": 306990, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 3, "selected": true, "text": "<ContentControl Template=\"{DynamicResource thirdPartyControlTemplate}\" />\n" }, { "answer_id": 307032, "author...
2008/11/20
[ "https://Stackoverflow.com/questions/306839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29676/" ]
306,840
<p>I have a working makefile that builds with mingw32. Now i renamed that makefile to Makefile.w32 (source -> <a href="http://pastie.org/319964" rel="nofollow noreferrer">http://pastie.org/319964</a>)</p> <p>Now i have a Makefile with the following. The problem is, it does not build my source</p> <pre><code>all: make mingw32 clean: @echo "causes an infinite loop -&gt; make mingw32 clean" mingw32: @echo "yeahhhhhhhhh" make Makefile.w32 mingw32-clean: @echo "mingw clean" make Makefile.w32 clean </code></pre> <p>result:</p> <pre><code>&gt; "make" make mingw32 make[1]: Entering directory `/c/nightly/test' yeahhhhhhhhh make Makefile.w32 make[2]: Entering directory `/c/nightly/test' make[2]: Nothing to be done for `Makefile.w32'. make[2]: Leaving directory `/c/nightly/test' make[1]: Leaving directory `/c/nightly/test' </code></pre> <p>It seems to me it doesn't like Makefile.w32 extension. I dont understand why it isn't building. It;s obviously getting to my "make Makefile.w32" line.</p>
[ { "answer_id": 306854, "author": "Sherm Pendley", "author_id": 27631, "author_profile": "https://Stackoverflow.com/users/27631", "pm_score": 3, "selected": true, "text": "make -f Makefile.w32\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/306840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
306,852
<p>I have a C# application that is a client to a web service. One of my requirements is to allow capturing the SOAP that I send, so that if there is a problem, I can either fix the bug, or demonstrate that the problem is in the service I am calling.</p> <p>My WebReference proxy service class derives from <code>System.Web.Services.Protocols.SoapHttpClientProtocol</code> as usual. If I had a magic wand, I would make this base class implement an event <code>OnPost</code> that I could handle to write the SOAP into my logs and continue.</p> <p>Short of running a packet sniffer like WireShark, is there an easy way to get this level of logging?</p>
[ { "answer_id": 21592590, "author": "bnieland", "author_id": 279393, "author_profile": "https://Stackoverflow.com/users/279393", "pm_score": 2, "selected": false, "text": "mySoapHttpClientProtocol.Url = mySoapHttpClientProtocol.Url.Replace(\"localhost\", \"localhost.fiddler\");\n" }, ...
2008/11/20
[ "https://Stackoverflow.com/questions/306852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7475/" ]
306,859
<p>I have a ContextMenuStrip that contains a submenu of dynamically generated ToolStripMenuItems. There are up to 80 sub menu items. Pressing the first letter of a desired menu item selects it correctly, but if the item happens to be out of the visible range (in a range handled by the scroll arrows), it isn't displayed - the user has to press the up arrow and then the down arrow for the desired option to be displayed &amp; focussed on the screen.</p> <p>As an example, I have 6 items starting with "m" but only 3.5 are visible. I hit m one and the first item is highlighted, I hit m 3 more times and I can see half a selected row (it's at the bottom of the visible area), hit m two more times, and I can't see the select row, then m one more time and the first m entry is visible and selected again.</p> <p>By default ToolStripMenuItems (TSMI) don't have key listeners available, however if I subclass the TSMI I can catch ProcessDialogKey and ProcessCmdKey and manually select the right option, but I am unable to scroll the toolstrip sub menu down to ensure my option is visible.</p> <p>Any tips on how to either:</p> <p><strong>a)</strong> scroll a tool strip's sub menu </p> <p>or</p> <p><strong>b)</strong> allow the sub menu to use multiple columns (and hope the user doesn't have a ridiculously low resolution).</p>
[ { "answer_id": 21592590, "author": "bnieland", "author_id": 279393, "author_profile": "https://Stackoverflow.com/users/279393", "pm_score": 2, "selected": false, "text": "mySoapHttpClientProtocol.Url = mySoapHttpClientProtocol.Url.Replace(\"localhost\", \"localhost.fiddler\");\n" }, ...
2008/11/20
[ "https://Stackoverflow.com/questions/306859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1484/" ]
306,862
<p>Today my colleagues and me have a discussion about the usage of the <code>final</code> keyword in Java to improve the garbage collection.</p> <p>For example, if you write a method like:</p> <pre><code>public Double doCalc(final Double value) { final Double maxWeight = 1000.0; final Double totalWeight = maxWeight * value; return totalWeight; } </code></pre> <p>Declaring the variables in the method <code>final</code> would help the garbage collection to clean up the memory from the unused variables in the method after the method exits.</p> <p>Is this true? </p>
[ { "answer_id": 306893, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 5, "selected": false, "text": "final" }, { "answer_id": 306900, "author": "Aaron", "author_id": 19130, "author_profile": "https://Stackove...
2008/11/20
[ "https://Stackoverflow.com/questions/306862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34856/" ]
306,863
<p>I know this isn't really what XPath is for but if I have a HashMap of XPath expressions to values how would I go about building an XML document. I've found dom-4j's DocumentHelper.makeElement(branch, xpath) except it is incapable of creating attributes or indexing. Surely a library exists that can do this?</p> <pre><code>Map xMap = new HashMap(); xMap.put("root/entity/@att", "fooattrib"); xMap.put("root/array[0]/ele/@att", "barattrib"); xMap.put("root/array[0]/ele", "barelement"); xMap.put("root/array[1]/ele", "zoobelement"); </code></pre> <p>would result in:</p> <pre><code>&lt;root&gt; &lt;entity att="fooattrib"/&gt; &lt;array&gt;&lt;ele att="barattrib"&gt;barelement&lt;/ele&gt;&lt;/array&gt; &lt;array&gt;&lt;ele&gt;zoobelement&lt;/ele&gt;&lt;/array&gt; &lt;/root&gt; </code></pre>
[ { "answer_id": 306893, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 5, "selected": false, "text": "final" }, { "answer_id": 306900, "author": "Aaron", "author_id": 19130, "author_profile": "https://Stackove...
2008/11/20
[ "https://Stackoverflow.com/questions/306863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
306,867
<p>I have a problem where I cannot identify visitors to my intranet page because their browser is configured to use a proxy, even for the local intranet. I always see the proxy IP and no other details about the client. The SOE that my company uses has the proxy set up already for Firefox and Internet Explorer, and I cannot ask them to reconfigure their browser because that is fairly complicated. I have tried using the PHP <code>$_SERVER['REMOTE_ADDR']</code> and also one called <code>$HTTP_SERVER_VARS['HTTP_X_FORWARD_FOR']</code>. In fact, I wrote a page that lists both the <code>$_SERVER</code> and <code>$HTTP_SERVER_VARS</code> arrays and there was nothing informative of the actual client connecting. This is why I think it needs to be done on the client's side.</p> <p>I'm not looking for a secure solution because it is only a simple page, so I was hoping that I could use Javascript or something similar to find something revealing about the client and send it to my intranet page as a <code>GET</code> variable. It's basically for collating statistics. It is no use telling me most of the visitors are a proxy! :)</p> <p>I also want to avoid having users log in if possible.</p>
[ { "answer_id": 306882, "author": "Sijin", "author_id": 8884, "author_profile": "https://Stackoverflow.com/users/8884", "pm_score": 1, "selected": false, "text": "HTTP-X-FORWARD-FOR" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/306867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10320/" ]
306,871
<p>A table exists that someone else loaded. I need to query against the table, but the lack of indexes makes the query plan abysmal. What I would like to do is detect if there is an index for a particular column, so that I can created it if it does not exist, and not create it if it is already there.</p> <p>Thanks.</p> <p>Evil</p>
[ { "answer_id": 306881, "author": "BQ.", "author_id": 4632, "author_profile": "https://Stackoverflow.com/users/4632", "pm_score": 2, "selected": false, "text": "Select * from sys.all_ind_columns where table_name=:TabName and table_owner=:TabOwner;\n" }, { "answer_id": 306895, ...
2008/11/20
[ "https://Stackoverflow.com/questions/306871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
306,877
<p>I wanted to deserialize an XML message containing an element that can be marked <code>nil="true"</code> into a class with a property of type <code>int?</code>. The only way I could get it to work was to write my own <code>NullableInt</code> type which implements <code>IXmlSerializable</code>. Is there a better way to do it?</p> <p>I wrote up the full problem and the way I solved it <a href="http://alexscordellis.blogspot.com/2008/11/using-xmlserializer-to-deserialize-into.html" rel="nofollow noreferrer">on my blog</a>.</p>
[ { "answer_id": 306980, "author": "Phil Jenkins", "author_id": 35496, "author_profile": "https://Stackoverflow.com/users/35496", "pm_score": 4, "selected": true, "text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<entities xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type...
2008/11/20
[ "https://Stackoverflow.com/questions/306877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12006/" ]
306,880
<pre><code>ArrayList &lt;String&gt; list = new ArrayList(); list.add("behold"); list.add("bend"); list.add("bet"); list.add("bear"); list.add("beat"); list.add("become"); list.add("begin"); </code></pre> <p>There is a way to search for the regexp bea.* and get the indexes like in ArrayList.indexOf ?</p> <p>EDIT: returning the items is fine but I need something with more performance than a Linear search</p>
[ { "answer_id": 306954, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 3, "selected": false, "text": "import java.util.regex.Pattern;\nimport java.util.ListIterator;\nimport java.util.ArrayList;\n\n/**\n * Finds the index of all...
2008/11/20
[ "https://Stackoverflow.com/questions/306880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14015/" ]
306,894
<p>As a beginning programmer, I'm trying to settle on a standard naming convention for myself. I realize that it's personal preference, but I was trying to get some ideas from some of you (well a LOT of you) who are much smarter than myself.</p> <p>I'm not talking about camel notation but rather how do you name your variables, etc. IMHO, var_Quantity is much more descriptive than Q or varQ. However, how do you keep the variable from becoming too long. I've tried to be more descriptive with naming my controls, but I've ended up with some like "rtxtboxAddrLine1" for a RadTextBox that holds address line 1. Too me,that is unmanageable, although it's pretty clear what that control is.</p> <p>I'm just curious if you have some guides that you follow or am I left up to my own devices?</p>
[ { "answer_id": 306923, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 5, "selected": true, "text": "quantity" }, { "answer_id": 307003, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "ht...
2008/11/20
[ "https://Stackoverflow.com/questions/306894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38317/" ]
306,896
<p>Is it possible to use EventListener to Listen to a variable and detect when the value of that variable changes? Thanks.</p>
[ { "answer_id": 318639, "author": "Brian Hodge", "author_id": 20628, "author_profile": "https://Stackoverflow.com/users/20628", "pm_score": 5, "selected": true, "text": "someVar = 5" }, { "answer_id": 787834, "author": "Community", "author_id": -1, "author_profile": "h...
2008/11/20
[ "https://Stackoverflow.com/questions/306896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34797/" ]
306,901
<p>When I run a wxPython application, it prints the string &ldquo;Redirecting output to win32trace remote collector&rdquo;and I must open PythonWin's trace collector tool to view that trace output.</p> <p>Since I'm not interested in collecting this output, how should I disable this feature?</p>
[ { "answer_id": 306925, "author": "joeforker", "author_id": 36330, "author_profile": "https://Stackoverflow.com/users/36330", "pm_score": 1, "selected": false, "text": "class MyApp(wx.App):\n def __init__(self):\n # Prevent wxPython from redirecting stdout/stderr:\n super...
2008/11/20
[ "https://Stackoverflow.com/questions/306901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36330/" ]
306,906
<p>I would like to find all the rows in a table and match on an exact case sensitive string. Unfortunately, my table has the case insensitive collation. </p> <p>What is the most efficient way to perform this.</p> <p>Eg.</p> <p>I would like the following to return no rows:</p> <pre><code>select * from sysobject where name = 'Sysbinobjs' </code></pre> <p>For the answer assume @match is in a variable: </p> <pre><code>declare @match varchar(4000) set @match = 'sysbinobjs' </code></pre> <p><strong>EDIT</strong> </p> <p>Clarification, make sure trailing spaces are treated properly, I want an exact match that takes account of trailing spaces so 'Hello' will only be matched with 'Hello' and not with 'Hello ' </p>
[ { "answer_id": 306918, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 4, "selected": true, "text": "declare @match nvarchar(4000) \nset @match = 'sysbinobjs'\n\n\nselect * from sysobjects\nwhere name = @match and\ncast(...
2008/11/20
[ "https://Stackoverflow.com/questions/306906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
306,924
<p>Is it possible to set the size of a checkbox using CSS or HTML across browsers? </p> <p><code>width</code> and <code>size</code> work in IE6+, but not with Firefox, where the checkbox stays 16x16 even if I set a smaller size.</p>
[ { "answer_id": 3132509, "author": "Avi Flax", "author_id": 7012, "author_profile": "https://Stackoverflow.com/users/7012", "pm_score": 3, "selected": false, "text": "-webkit-transform: scale(1.3, 1.3);" }, { "answer_id": 10415275, "author": "jdw", "author_id": 1370191, ...
2008/11/20
[ "https://Stackoverflow.com/questions/306924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39474/" ]
306,937
<p>What is the cast expression equivalent of VB.NET's CType in Visual Basic 6?</p>
[ { "answer_id": 306944, "author": "JohnFx", "author_id": 30018, "author_profile": "https://Stackoverflow.com/users/30018", "pm_score": 5, "selected": true, "text": "cint() Cast to integer\ncstr() cast to string\nclng() cast to long\ncdbl() cast to double\ncdate() cast to date\n" }, { ...
2008/11/20
[ "https://Stackoverflow.com/questions/306937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35286/" ]
306,938
<p>We currently have an appserver setup where EVERYTHING is off of one big context root, and we copy class files and restart app servers to deploy. Not ideal. I'm trying to set up an ant script to do the build and deploy using wdeploy, and everything works, except I need my servlet to forward to jsps outside of the context root of my war file deploy. So I figure if I can put a symlink in my war file, it can point to somewhere outside of my context root space.</p> <p>This is the goal I'm trying to achieve, perhaps the symlink isn't the best idea. I just need a way to forward outside of my context root from a servlet.</p>
[ { "answer_id": 306944, "author": "JohnFx", "author_id": 30018, "author_profile": "https://Stackoverflow.com/users/30018", "pm_score": 5, "selected": true, "text": "cint() Cast to integer\ncstr() cast to string\nclng() cast to long\ncdbl() cast to double\ncdate() cast to date\n" }, { ...
2008/11/20
[ "https://Stackoverflow.com/questions/306938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12386/" ]
306,945
<p>I have a very long-running stored procedure in SQL Server 2005 that I'm trying to debug, and I'm using the 'print' command to do it. The problem is, I'm only getting the messages back from SQL Server at the very end of my sproc - I'd like to be able to flush the message buffer and see these messages immediately during the sproc's runtime, rather than at the very end.</p>
[ { "answer_id": 307005, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 9, "selected": true, "text": "RAISERROR" }, { "answer_id": 4068129, "author": "tcbrazil", "author_id": 391029, "author_profile": ...
2008/11/20
[ "https://Stackoverflow.com/questions/306945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16942/" ]
306,946
<p>need ask you about some help.</p> <p>I have web app running in Net 2.0.<br> I wanna ask what storage (cache, session, file) I should use for my objects as they have different scope of using. Can be divide into several groups:<br> 1) objects related directly to visitor (e.g. details about visitor that are received after authentication)<br> 2) objects that are used for every visitor, so its scope of application (some init data, common data) </p> <p>Most of these objects get data from web service, which is expensive.</p> <p>So what's my best choices considering speed, memory, accessibility and what else I should look out.</p> <p>Any help most welcome. Thanks, X.</p>
[ { "answer_id": 306978, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 3, "selected": true, "text": "Session" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/306946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24507/" ]
306,968
<p>I have a linux box with a bank of modems and need to create demand-dial (outbound) PPP connections to a very large set of remote machines. Since I have far more remotes than local modems, I'd like to launch one or more instances of <code>pppd</code> in <code>demand</code> mode, but not allocate a particular modem until a connection is requested. When the connection becomes idle, I'd like <code>pppd</code> to release the modem so it can be used for a connection to a different remote.</p> <p>I've been through the <code>pppd man</code> pages and understand the concepts of the <code>call</code> and <code>connect</code> options, as well as the <code>options.DEVICE</code> files and the <code>/etc/ppp/peers</code> directory. Lock files will tell me which modems are in use or available. And I'm able to connect to multiple remote peers as long as I hard-code the modem assignments. But I haven't found a way to assign them dynamically, say by calling a <code>get_available_modem</code> script when <code>pppd</code> needs to dial. Google doesn't seem to know, either.</p> <p>A work-around might be to detect the need to demand-dial with an external mechanism, and then launch <code>pppd</code> to service it, but it seems cleaner to leverage the facility within <code>pppd</code> itself.</p> <p>Any pointers or ideas are appreciated. Thanks for your thoughts!</p>
[ { "answer_id": 361114, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 2, "selected": true, "text": "/dev/modem0" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/306968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29157/" ]
306,992
<p>I have found an example for encrypting a web.config during installation <a href="http://madtechnology.wordpress.com/2007/05/04/using-wix-to-secure-a-connection-string/" rel="nofollow noreferrer">here</a>, but my app is a windows service. The <code>aspnetreg_iis</code> method works only for web.config files.</p> <p>I know how to programatically encrypt the config file, but I don't think I can do that using WiX. Am I wrong? Any ideas?</p>
[ { "answer_id": 307080, "author": "AJ.", "author_id": 27457, "author_profile": "https://Stackoverflow.com/users/27457", "pm_score": 2, "selected": false, "text": "//class global\nstatic System.Reflection.Assembly DefiningAssembly;\n\nAppDomain currentDomain = AppDomain.CurrentDomain;\ncur...
2008/11/20
[ "https://Stackoverflow.com/questions/306992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1865/" ]
307,004
<p>On several of my usercontrols, I change the cursor by using</p> <pre><code>this.Cursor = Cursors.Wait; </code></pre> <p>when I click on something.</p> <p>Now I want to do the same thing on a WPF page on a button click. When I hover over my button, the cursor changes to a hand, but when I click it, it doesn't change to the wait cursor. I wonder if this has something to do with the fact that it's a button, or because this is a page and not a usercontrol? This seems like weird behavior.</p>
[ { "answer_id": 307020, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 9, "selected": true, "text": "Mouse.OverrideCursor = Cursors.Wait;\ntry\n{\n // do stuff\n}\nfinally\n{\n Mouse.OverrideCursor = null;\n}\n" },...
2008/11/20
[ "https://Stackoverflow.com/questions/307004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
307,006
<p>I'm working on an application controller for a program that is spitting text directly to /dev/tty.</p> <p>This is a production application controller that must be able to catch all text going to the terminal. Generally, this isn't a problem. We simply redirect stdout and stderr. This particular application is making direct calls to echo and redirecting the result to /dev/tty (<code>echo "some text" &gt; /dev/tty</code>). Redirects via my application controller are failing to catch the text.</p> <p>I do have the source for this application, but am not in a position to modify it, nor is it being maintained anymore. Any ideas on how to catch and/or throw away the output? </p>
[ { "answer_id": 307328, "author": "flolo", "author_id": 36472, "author_profile": "https://Stackoverflow.com/users/36472", "pm_score": 2, "selected": false, "text": " screen -D -m yourEvilProgram\n" }, { "answer_id": 307505, "author": "Jonathan Leffler", "author_id": 15168,...
2008/11/20
[ "https://Stackoverflow.com/questions/307006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19741/" ]
307,013
<p>This is for .NET. IgnoreCase is set and MultiLine is NOT set.</p> <p>Usually I'm decent at regex, maybe I'm running low on caffeine...</p> <p>Users are allowed to enter HTML-encoded entities (&lt;lt;, &lt;amp;, etc.), and to use the following HTML tags:</p> <pre><code>u, i, b, h3, h4, br, a, img </code></pre> <p>Self-closing &lt;br/&gt; and &lt;img/&gt; are allowed, with or without the extra space, but are not required.</p> <p>I want to:</p> <ol> <li>Strip all starting and ending HTML tags other than those listed above. </li> <li>Remove attributes from the remaining tags, <em>except</em> anchors can have an href.</li> </ol> <p>My search pattern (replaced with an empty string) so far:</p> <pre><code>&lt;(?!i|b|h3|h4|a|img|/i|/b|/h3|/h4|/a|/img)[^&gt;]+&gt; </code></pre> <p>This <em>seems</em> to be stripping all but the start and end tags I want, but there are three problems:</p> <ol> <li>Having to include the end tag version of each allowed tag is ugly.</li> <li>The attributes survive. Can this happen in a single replacement?</li> <li>Tags <em>starting with</em> the allowed tag names slip through. E.g., "&lt;abbrev&gt;" and "&lt;iframe&gt;".</li> </ol> <p>The following suggested pattern does not strip out tags that have no attributes.</p> <pre><code>&lt;/?(?!i|b|h3|h4|a|img)\b[^&gt;]*&gt; </code></pre> <p>As mentioned below, "&gt;" is legal in an attribute value, but it's safe to say I won't support that. Also, there will be no CDATA blocks, etc. to worry about. Just a little HTML.</p> <p>Loophole's answer is the best one so far, thanks! Here's his pattern (hoping the PRE works better for me):</p> <pre><code>static string SanitizeHtml(string html) { string acceptable = "script|link|title"; string stringPattern = @"&lt;/?(?(?=" + acceptable + @")notag|[a-zA-Z0-9]+)(?:\s[a-zA-Z0-9\-]+=?(?:([""']?).*?\1?)?)*\s*/?&gt;"; return Regex.Replace(html, stringPattern, "sausage"); } </code></pre> <p>Some small tweaks I think could still be made to this answer:</p> <ol> <li><p>I think this could be modified to capture simple HTML comments (those that do not themselves contain tags) by adding "!--" to the "acceptable" variable and making a small change to the end of the expression to allow for an optional trailing "\s--".</p></li> <li><p>I think this would break if there are multiple whitespace characters between attributes (example: heavily-formatted HTML with line breaks and tabs between attributes).</p></li> </ol> <p><strong>Edit 2009-07-23:</strong> Here's the final solution I went with (in VB.NET):</p> <pre><code> Dim AcceptableTags As String = "i|b|u|sup|sub|ol|ul|li|br|h2|h3|h4|h5|span|div|p|a|img|blockquote" Dim WhiteListPattern As String = "&lt;/?(?(?=" &amp; AcceptableTags &amp; _ ")notag|[a-zA-Z0-9]+)(?:\s[a-zA-Z0-9\-]+=?(?:([""']?).*?\1?)?)*\s*/?&gt;" html = Regex.Replace(html, WhiteListPattern, "", RegExOptions.Compiled) </code></pre> <p>The caveat is that the HREF attribute of A tags still gets scrubbed, which is not ideal.</p>
[ { "answer_id": 308367, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 1, "selected": false, "text": "<(?!/?(i|b|h3|h4|a|img)\\b)[^>]+>\n" }, { "answer_id": 315823, "author": "Jason Kelley", "author_id"...
2008/11/20
[ "https://Stackoverflow.com/questions/307013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16306/" ]
307,014
<p>A client of mine has told me the program I made for them won't connect to a SQL server named instance, I have a standard SQL server with no named instance so I'm wondering how I can test this. A named instance connection string look like the one below, could the backslash be were my code fails?</p> <p>Driver={SQL Native Client};Server=myServerName\theInstanceName;Database=myDataBase; </p> <p>My code is as follows:</p> <pre><code>sqlServer=s.Substring(keyword.Length,s.Length-keyword.Length); FormODBC formODBC=new FormODBC(this); formODBC.SetSqlServer(sqlServer,dbUsername,dbPassword,database,table); formODBC.ReadData(); </code></pre> <p>How should I handle the backslash as I suspect this may be the problem?</p> <p>Thanks</p>
[ { "answer_id": 309877, "author": "D'Arcy Rittich", "author_id": 39430, "author_profile": "https://Stackoverflow.com/users/39430", "pm_score": 2, "selected": false, "text": "string server = \"myServer\\\\myInstance\";\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
307,015
<p>This isn't working. Can this be done in find? Or do I need to xargs?</p> <pre><code>find -name 'file_*' -follow -type f -exec zcat {} \| agrep -dEOE 'grep' \; </code></pre>
[ { "answer_id": 307023, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 4, "selected": false, "text": "find . -name \"file_*\" -follow -type f -print0 | xargs -0 zcat | agrep -dEOE 'grep'\n" }, { "answer_id": 30715...
2008/11/20
[ "https://Stackoverflow.com/questions/307015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34594/" ]
307,019
<p>The following query returns strange results for me:</p> <pre><code>SELECT `Statistics`.`StatisticID`, COUNT(`Votes`.`StatisticID`) AS `Score`, COUNT(`Views`.`StatisticID`) AS `Views`, COUNT(`Comments`.`StatisticID`) AS `Comments` FROM `Statistics` LEFT JOIN `Votes` ON `Votes`.`StatisticID` = `Statistics`.`StatisticID` LEFT JOIN `Views` ON `Views`.`StatisticID` = `Statistics`.`StatisticID` LEFT JOIN `Comments` ON `Comments`.`StatisticID` = `Statistics`.`StatisticID` GROUP BY `Statistics`.`StatisticID` LIMIT 0, 10 </code></pre> <p>I'm querying this on a table structure like the following:</p> <p>(only data relevant to <code>Statistics.StatisticID = 8</code>)</p> <h3>Votes</h3> <pre><code>StatisticID 8 </code></pre> <h3>Views</h3> <pre><code>StatisticID 8 8 </code></pre> <h3>Comments</h3> <pre><code>StatisticID 8 8 8 8 8 </code></pre> <p>Now if I run this query I get the following result set:</p> <pre><code>StatisticID Score Views Comments 8 5 5 5 </code></pre> <p>I knwo where the 5 comes from - the number of Comments - and this works if I take the comments statement out. Can anyone debug this as this is out of my reach (I'm relatively new with SQL).</p> <p>Thanks, Ross</p>
[ { "answer_id": 307303, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": 3, "selected": true, "text": "SELECT\n `Statistics`.`StatisticID`,\n COUNT(DISTINCT `Votes`.`VoteID`) AS `Score`,\n COUNT(DISTINCT `Views`.`Vi...
2008/11/20
[ "https://Stackoverflow.com/questions/307019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2025/" ]
307,024
<p>A link that stands out is <a href="http://www.devdaily.com/blog/post/jfc-swing/handling-main-mac-menu-in-swing-application/" rel="noreferrer">http://www.devdaily.com/blog/post/jfc-swing/handling-main-mac-menu-in-swing-application/</a> however the menu bar under Mac OS X displays as the package name as opposed to the application name. I'm using the code in the above link without any luck, so I'm unsure if anything's changed in recent Mac OS versions.</p> <p>Here's an extract:</p> <blockquote> <pre><code>public RootGUI() { super("Hello"); JMenuBar menuBar = new JMenuBar(); JMenu file = new JMenu("File"); JMenuItem item = new JMenuItem("Woah"); file.add(item); menuBar.add(file); setJMenuBar(menuBar); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(100, 100); pack(); setVisible(true); } </code></pre> </blockquote> <pre><code>public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { try { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Test"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); new RootGUI(); } catch(ClassNotFoundException e) { System.out.println("ClassNotFoundException: " + e.getMessage()); } catch(InstantiationException e) { System.out.println("InstantiationException: " + e.getMessage()); } catch(IllegalAccessException e) { System.out.println("IllegalAccessException: " + e.getMessage()); } catch(UnsupportedLookAndFeelException e) { System.out.println("UnsupportedLookAndFeelException: " + e.getMessage()); } } }); } </code></pre> <p>The first menu item on the menu bar should display as "test", unfortunately this isn't the case. The file menu works fine, on the other hand. Any ideas?</p>
[ { "answer_id": 307996, "author": "Daniel Hiller", "author_id": 16193, "author_profile": "https://Stackoverflow.com/users/16193", "pm_score": 2, "selected": false, "text": "-Xdock:name=\"YourNameHere\"\n" }, { "answer_id": 310575, "author": "Matt Solnit", "author_id": 6198...
2008/11/20
[ "https://Stackoverflow.com/questions/307024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39693/" ]
307,027
<p>I'm wondering if this is a good design. I have a number of tables that require address information (e.g. street, post code/zip, country, fax, email). Sometimes the same address will be repeated multiple times. For example, an address may be stored against a supplier, and then on each purchase order sent to them. The supplier may then change their address and any subsequent purchase orders should have the new address. It's more complicated than this, but that's an example requirement.</p> <p>Option 1 Put all the address columns as attributes on the various tables. Copy the details down from the supplier to the PO as it is created. Potentially store multiple copies of the </p> <p>Option 2 Create a separate address table. Have a foreign key from the supplier and purchase order tables to the address table. Only allow insert and delete on the address table as updates could change more than you intend. Then I would have some scheduled task that deletes any rows from the address table that are no longer referenced by anything so unused rows were not left about. Perhaps also have a unique constraint on all the non-pk columns in the address table to stop duplicates as well.</p> <p>I'm leaning towards option 2. Is there a better way?</p> <p>EDIT: I must keep the address on the purchase order as it was when sent. Also, it's a bit more complicated that I suggested as there may be a delivery address and a billing address (there's also a bunch of other tables that have address information).</p> <p>After a while, I will delete old purchase orders en-masse based on their date. It is after this that I was intending on garbage collecting any address records that are not referenced anymore by anything (otherwise it feels like I'm creating a leak).</p>
[ { "answer_id": 307111, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 6, "selected": true, "text": "Addresses\n---------\nAddressId (PK)\nStreet1\n... (etc)\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14663/" ]
307,030
<p>I have a working make, I have platform code and like several makes for each os in the folder. Right now I have one makefile which works. I renamed it to Makefile.ws and wrote this in Makefile</p> <pre><code>all: make -f Makefile.w32 clean: make -f Makefile.w32 clean </code></pre> <p>I ran it and got this error</p> <pre><code>&gt; "make" make -f Makefile.w32 make[1]: Entering directory `/c/nightly/test' make -f Makefile.w32 make[3]: Makefile.w32: No such file or directory make[3]: *** No rule to make target `Makefile.w32'. Stop. make[2]: *** [all] Error 2 make[1]: *** [build] Error 2 make[1]: Leaving directory `/c/nightly/test' "make": *** [all] Error 2 </code></pre> <p>Oddly enough the clean works perfectly. Then I decided to write "make -f Makefile.w32 mingw32" and that did not work correctly. In fact it made a folder called mingw32 which I thought was very strange.</p> <p>As for the mingw32 rule I just copy build which I suspect is the main/normal rule that is used to build</p> <pre><code>$(BUILD): @[ -d $@ ] || mkdir -p $@ @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile mingw32: @[ -d $@ ] || mkdir -p $@ @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile </code></pre> <p>full .w32 source is here <a href="http://pastie.org/320035" rel="nofollow noreferrer">http://pastie.org/320035</a></p>
[ { "answer_id": 307062, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 0, "selected": false, "text": "$(MAKE) -f ..." }, { "answer_id": 307067, "author": "JesperE", "author_id": 13051, "author_profile": "...
2008/11/20
[ "https://Stackoverflow.com/questions/307030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
307,041
<p>The rails books and web pages I've been following have all stuck to very simple projects for the sake of providing complete examples. I'm moving away from the small project app and into a realm of non-browser clients and need to decide where to put code that is shared by all involved parties.</p> <p>The non-browser client is a script that runs on any machine which can connect to the database. Browser clients write commands into the database, which the script examines and decides what to do. Upon completion, the script then writes its result back. The script is not started by the RoR server, but has access to its directory structure.</p> <p>Where would be the best place for shared code to live, and how would the RoR loader handle it? The code in question doesn't really belong in a model, otherwise I'd drop it in there and be done with it.</p>
[ { "answer_id": 307061, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 4, "selected": true, "text": "/lib" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30997/" ]
307,048
<p>Suddenly my Flex Apps can no longer connect to salesforce.com via its API, I am getting a security sandbox violation. Login credentials are correct, I have tried them via a different means, and I have obfuscated them below.</p> <p>This was working fine earlier today and I have not been coding since then.</p> <p>Anyone else come across this or know what's going on?</p> <p>Here is the exception returned to my app</p> <pre><code>Method name is: login 'A997F86A-36E9-DDDC-EC6B-BBEE23101466' producer connected. 'A997F86A-36E9-DDDC-EC6B-BBEE23101466' producer sending message 'B89E5879-D7F7-E91E-2082-BBEE231054DD' 'direct_http_channel' channel sending message: (mx.messaging.messages::HTTPRequestMessage)#0 body = "&lt;se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;se:Header xmlns:sfns="urn:partner.soap.sforce.com"/&gt;&lt;se:Body&gt;&lt;login xmlns="urn:partner.soap.sforce.com" xmlns:ns1="sobject.partner.soap.sforce.com"&gt;&lt;username&gt;simon.palmer@***.com&lt;/username&gt;&lt;password&gt;***&lt;/password&gt;&lt;/login&gt;&lt;/se:Body&gt;&lt;/se:Envelope&gt;" clientId = (null) contentType = "text/xml; charset=UTF-8" destination = "DefaultHTTPS" headers = (Object)#1 httpHeaders = (Object)#2 Accept = "text/xml" SOAPAction = """" X-Salesforce-No-500-SC = "true" messageId = "B89E5879-D7F7-E91E-2082-BBEE231054DD" method = "POST" recordHeaders = false timestamp = 0 timeToLive = 0 url = "https://www.salesforce.com/services/Soap/u/11.0" Method name is: login *** Security Sandbox Violation *** Connection to https://www.salesforce.com/services/Soap/u/11.0 halted - not permitted from https://localhost/pm_server/pm/pm-debug.swf 'A997F86A-36E9-DDDC-EC6B-BBEE23101466' producer acknowledge of 'B89E5879-D7F7-E91E-2082-BBEE231054DD'. 'A997F86A-36E9-DDDC-EC6B-BBEE23101466' producer fault for 'B89E5879-D7F7-E91E-2082-BBEE231054DD'. Comunication Error : Channel.Security.Error : Security error accessing url : Destination: DefaultHTTPS Error: Request for resource at https://www.salesforce.com/services/Soap/u/11.0 by requestor from https://localhost/pm_server/pm/pm-debug.swf is denied due to lack of policy file permissions. </code></pre>
[ { "answer_id": 339479, "author": "Simon", "author_id": 24039, "author_profile": "https://Stackoverflow.com/users/24039", "pm_score": 1, "selected": false, "text": "apex = new Connection(); \napex.serverUrl = \"https://na3.salesforce.com/services/Soap/u/14.0\";\napex.protocol = \"https...
2008/11/20
[ "https://Stackoverflow.com/questions/307048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24039/" ]
307,056
<p>What rules apply to the name that ends up in the exports section of an PE (Portable Executable)? Roughly, I see names starting with an '_' underscore, a '?' question mark or an '@' at-sign. What do those mean, and what about the rest of the name?</p> <p>Also - How can I reverse the naming convention into something more usable?</p>
[ { "answer_id": 307076, "author": "Eric", "author_id": 6367, "author_profile": "https://Stackoverflow.com/users/6367", "pm_score": 3, "selected": true, "text": "LIBRARY \"MyDll\"\n\nEXPORTS\n exportFunction1\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12170/" ]
307,060
<p>The function <a href="http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx" rel="noreferrer">CreateFileMapping</a> can be used to allocate space in the pagefile (if the first argument is <code>INVALID_HANDLE_VALUE</code>). The allocated space can later be memory mapped into the process virtual address space.</p> <p>Why would I want to do this instead of using just <a href="http://msdn.microsoft.com/en-us/library/aa366887(VS.85).aspx" rel="noreferrer">VirtualAlloc</a>?</p> <p>It seems that both functions do almost the same thing. Memory allocated by VirtualAlloc may at some point be pushed out to the pagefile. Why should I need an API that specifically requests that my pages be allocated there in the first instance? Why should I care where my private pages live?</p> <p>Is it just a hint to the OS about my expected memory usage patterns? (Ie, the former is a hint to swap out those pages more aggressively.)</p> <p>Or is it simply a convenience method when working with very large datasets on 32-bit processes? (Ie, I can use CreateFileMapping to make >4Gb allocations, then memory map smaller chunks of the space as needed. Using the pagefile saves me the work of manually managing my own set of files to "swap" to.)</p> <p>PS. This question is sparked by an article I read recently: <a href="http://blogs.technet.com/markrussinovich/archive/2008/11/17/3155406.aspx" rel="noreferrer">http://blogs.technet.com/markrussinovich/archive/2008/11/17/3155406.aspx</a></p>
[ { "answer_id": 307106, "author": "Kieveli", "author_id": 15852, "author_profile": "https://Stackoverflow.com/users/15852", "pm_score": 3, "selected": true, "text": "A single file mapping object can be shared by multiple processes.\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755/" ]
307,070
<p>I want to offload a block of code in my main process to child process to make it run concurrently. I also want to have the PID of the spawned child process so I can monitor and kill it if necessary.</p>
[ { "answer_id": 307088, "author": "Chris Lloyd", "author_id": 42413, "author_profile": "https://Stackoverflow.com/users/42413", "pm_score": 6, "selected": true, "text": "fork" }, { "answer_id": 307127, "author": "Martin Carpenter", "author_id": 39443, "author_profile":...
2008/11/20
[ "https://Stackoverflow.com/questions/307070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42413/" ]
307,073
<p>Consider the "double-check idiom for lazy initialization of instance fields":</p> <blockquote><pre>// Item 71 in Effective Java copied from <a href="http://java.sun.com/developer/technicalArticles/Interviews/bloch_effective_08_qa.html" rel="nofollow noreferrer">this interview with Bloch</a>. private volatile FieldType field; FieldType getField() { FieldType result = field; if (result == null) { // First check (no locking) synchronized(this) { result = field; if (result == null) // Second check (with locking) field = result = computeFieldValue(); } } return result; }</pre></blockquote> <p><p>I want to be able to reset the field in a safe way (force it to load again from the database, in my case). I assume that we could do this by having a reset method:</p> <blockquote><pre> void reset() { field = null; }</pre></blockquote> <p><p>Is this the standard way of doing resetting the field? Is it safe? Any pitfalls? I'm asking because Bloch gave the following warning about double-checked lazy-loading: "The idiom is very fast but also complicated and delicate, so don't be tempted to modify it in any way. Just copy and paste -- normally not a good idea, but appropriate here."</p> <p>Thanks in advance, Playa from the Himalayas.</p>
[ { "answer_id": 307206, "author": "jacobko", "author_id": 1318, "author_profile": "https://Stackoverflow.com/users/1318", "pm_score": 0, "selected": false, "text": "reset()" }, { "answer_id": 307225, "author": "erickson", "author_id": 3474, "author_profile": "https://S...
2008/11/20
[ "https://Stackoverflow.com/questions/307073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39489/" ]
307,082
<p>What is the shortest chunk of C++ you can come up with to safely clean up a <code>std::vector</code> or <code>std::list</code> of pointers? (assuming you have to call delete on the pointers?)</p> <pre><code>list&lt;Foo*&gt; foo_list; </code></pre> <p>I'd rather not use Boost or wrap my pointers with smart pointers.</p>
[ { "answer_id": 307090, "author": "John Dibling", "author_id": 241536, "author_profile": "https://Stackoverflow.com/users/241536", "pm_score": 3, "selected": false, "text": "template< typename T >\nstruct delete_ptr : public std::unary_function<T,bool>\n{\n bool operator()(T*pT) const {...
2008/11/20
[ "https://Stackoverflow.com/questions/307082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23524/" ]
307,084
<p>The .net framework 3.5 (or vista) provides me with an English voice (David I think) to use with the Speech.Synthesis api. I need a french voice to use with a french dictation practice app I am building for my kids to use to improve their french spelling. The api allows me to change culture when creating a voice, but the default English voice cannot pronounce the french words correctly.</p> <p>I have been unable to find any way to download a french voice from Microsoft. Is this possible? I did download a Demo commercial voice from Cepstral, but it is crippled in a way that makes it unusable (even for testing). I did not want to buy anything as this exercise is just for fun.</p> <p>I had hoped alternative language voices might be easily had without resort to the commercial professional voices. Any free alternatives?</p>
[ { "answer_id": 307090, "author": "John Dibling", "author_id": 241536, "author_profile": "https://Stackoverflow.com/users/241536", "pm_score": 3, "selected": false, "text": "template< typename T >\nstruct delete_ptr : public std::unary_function<T,bool>\n{\n bool operator()(T*pT) const {...
2008/11/20
[ "https://Stackoverflow.com/questions/307084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1400/" ]
307,089
<p>I've been looking for some guidelines on how to layout PHP code. I've found some good references, such as the following:</p> <p><a href="http://www.dagbladet.no/development/phpcodingstandard/" rel="nofollow noreferrer">http://www.dagbladet.no/development/phpcodingstandard/</a></p> <p>and <a href="https://stackoverflow.com/questions/5214/whats-a-good-standard-code-layout-for-a-php-application">this question</a> on SO.</p> <p>However, none of that quite gets to what I'm specifically wondering about, which is the integration of HTML and PHP. For example:</p> <ol> <li>Is it OK to have a PHP file that starts out with HTML tags and only has PHP inserted where needed? Or should you just have one section of PHP code that contains everything?</li> <li>If you have a chunk of PHP code in the middle of which is a set of <code>echo</code>'s that just output a fixed bit of HTML, is it better to break out of PHP and just put in the HTML directly?</li> <li>Should functions all be defined in dedicated PHP files, or is it OK to define a bunch of functions at the top of a file and call them later on in that same file?</li> </ol> <p>There are probably other questions I'd like to ask, but really I'm looking for someone to point me at some kind of resource online that offers guidance on the general idea of how HTML and PHP should be combined together.</p>
[ { "answer_id": 307164, "author": "Nick Van Brunt", "author_id": 30470, "author_profile": "https://Stackoverflow.com/users/30470", "pm_score": 2, "selected": false, "text": "index.php" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
307,094
<p>I have a couple of tables that I want to map to classes. The tables look like this:</p> <pre><code>Asset --------- AssetId AssetName Product --------- ProductId ProductName AssetId Disposal --------- DisposalId AssetId DisposalDate </code></pre> <p>Basically what I want to do is join the Product Table to the Disposal table on AssetId so that my Product has a collection of Disposals joined by asset. I have defined the following mapping but NHibernate (1.2) seems to ignore the key column defined in the bag and chooses to join the Product table to the Disposal table by ProductId (ie Product.ProductId = Disposal.AssetId). I'm not sure if this is a bug or if I'm not defining it properly but if anyone has a way to do this I'd be most greatful.</p> <pre><code> &lt;class name="Product" table="Product" lazy="false"&gt; &lt;id name="ProductId" column="ProductId" type="int"&gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;property name="ProductName" column="ProductName"/&gt; &lt;bag name="Disposals" fetch="join" &gt; &lt;key column="AssetId" foreign-key="AssetId/&gt; &lt;many-to-many class="Disposal"/&gt; &lt;/bag&gt; &lt;/class&gt; </code></pre>
[ { "answer_id": 750741, "author": "Stefan Steinegger", "author_id": 2658202, "author_profile": "https://Stackoverflow.com/users/2658202", "pm_score": 1, "selected": true, "text": " <class name=\"Product\" table=\"Product\" lazy=\"false\">\n <id name=\"ProductId\" column=\"ProductId\" ...
2008/11/20
[ "https://Stackoverflow.com/questions/307094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
307,096
<p>When using tables in a CSS-based layout, I've noticed if I have a table with 4 columns (2 on the side are small for spacing, 2 in the middle are for content), when I type content in one of the two middle columns, it will stay at the top, which is perfect.</p> <p>However, if I type content in the other middle column, and press enter, the content in the other middle content will come down.</p> <p>This means I can never type content in the two columns while keeping the content in both columns glued to the top (roof) of the table column. I have tried everything, is there a way I can do this? If I can't do this, my content looks wonky as it's not level in the two columns, and thus unprofessional.</p>
[ { "answer_id": 307186, "author": "Zack The Human", "author_id": 18265, "author_profile": "https://Stackoverflow.com/users/18265", "pm_score": 1, "selected": false, "text": "td {\n vertical-align:top;\n}\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
307,098
<p>i get a Keyword not supported: '192.168.1.1;initial catalog'. error when trying to do this </p> <p><code>Dim cn As New SqlConnection(str)</code> </p> <p>where str is the connection string starts with '192.168.1.1;initial catalog' ... I have not specified the provider in the connection string</p>
[ { "answer_id": 307114, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 5, "selected": true, "text": "Dim str As String\nstr = \"Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;\"\n\nD...
2008/11/20
[ "https://Stackoverflow.com/questions/307098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
307,120
<p>I need to set a system environment variable from a Bash script that would be available outside of the current scope. So you would normally export environment variables like this:</p> <pre><code>export MY_VAR=/opt/my_var </code></pre> <p>But I need the environment variable to be available at a system level though. Is this possible?</p>
[ { "answer_id": 307145, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 4, "selected": false, "text": "source {script}\n" }, { "answer_id": 307204, "author": "Jeremy Cantrell", "author_id": 18866, "au...
2008/11/20
[ "https://Stackoverflow.com/questions/307120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18228/" ]
307,128
<p>I'm having trouble with this code:</p> <pre><code>NSRect itemFrame; id item; // code to assign item goes here. itemFrame.origin.y -= [item respondsToSelector:@selector(selectedHeight)] ? [item selectedHeight] : [self defaultSelectedHeight]; </code></pre> <p>This is the problematic bit:</p> <pre><code>[item selectedHeight] </code></pre> <p>The compiler is assuming that the return type is id. I though that adding a cast would fix this:</p> <pre><code>(float)[item selectedHeight] </code></pre> <p>but it doesn't work. </p> <p>What am I doing wrong? (I suspect the problem is to do with resolving pointers related to id but I can't find any relevant documentation).</p>
[ { "answer_id": 307146, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 1, "selected": false, "text": "selectedHeight" }, { "answer_id": 307147, "author": "e.James", "author_id": 33686, "author_pr...
2008/11/20
[ "https://Stackoverflow.com/questions/307128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
307,141
<p>I need to test for general URLs using any protocol (http, https, shttp, ftp, svn, mysql and things I don't know about).</p> <p>My first pass is this:</p> <pre><code>\w+://(\w+\.)+[\w+](/[\w]+)(\?[-A-Z0-9+&amp;@#/%=~_|!:,.;]*)? </code></pre> <p>(<a href="http://perldoc.perl.org/perlre.html" rel="nofollow noreferrer">PCRE</a> and <a href="http://msdn.microsoft.com/en-us/library/hs600312.aspx" rel="nofollow noreferrer">.NET</a> so nothing to fancy)</p>
[ { "answer_id": 307142, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 2, "selected": false, "text": "[\\w+-]+://([a-zA-Z0-9]+\\.)+[[a-zA-Z0-9]+](/[%\\w]+)(\\?[-A-Z0-9+&@#/%=~_|!:,.;]*)?\n" }, { "answer_id": 307182, "a...
2008/11/20
[ "https://Stackoverflow.com/questions/307141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
307,148
<p>Vim is acting slow when I scroll. The cursor skips some lines when I'm pressing j/k continually.</p> <p>I'm using xterm and urxvt. In both vim acts like this.</p> <p>This happens locally, with small or big files. I do use Control + F/B they work just fine.</p> <p>EDIT: ttyfast in small files did the trick but in bigger is the same. When running without customization it goes allright.</p>
[ { "answer_id": 307175, "author": "Jeremy Cantrell", "author_id": 18866, "author_profile": "https://Stackoverflow.com/users/18866", "pm_score": 7, "selected": true, "text": ":help 'ttyfast'\n" }, { "answer_id": 378967, "author": "Cyber Oliveira", "author_id": 9793, "au...
2008/11/20
[ "https://Stackoverflow.com/questions/307148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36532/" ]
307,152
<p>What do I gain by adding a timestamp column called recordversion to a table in ms-sql?</p>
[ { "answer_id": 307261, "author": "TravisO", "author_id": 35116, "author_profile": "https://Stackoverflow.com/users/35116", "pm_score": 1, "selected": false, "text": "CreatedBy(varchar) | CreatedOn(date) | ModifiedBy(varchar) | ModifiedOn(date)\n" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
307,179
<p>Is this defined by the language? Is there a defined maximum? Is it different in different browsers?</p>
[ { "answer_id": 307194, "author": "Peter Bailey", "author_id": 8815, "author_profile": "https://Stackoverflow.com/users/8815", "pm_score": 9, "selected": false, "text": "Number.MIN_SAFE_INTEGER;\nNumber.MAX_SAFE_INTEGER;\n" }, { "answer_id": 307200, "author": "Jimmy", "aut...
2008/11/20
[ "https://Stackoverflow.com/questions/307179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5657/" ]
307,183
<p>In .NET is there a function that tests if a string is syntactically a correct path? I specifically don't want it to test if the path actually exists.</p> <p>my current take on this is a regex:</p> <pre><code>([a-zA-Z]:|\\)?\\?([^/\\:*?"&lt;&gt;|]+[/\\])*[^/\\:*?"&lt;&gt;|]* </code></pre> <p>matches:</p> <pre><code>c:\ bbbb \\bob/john\ ..\..\ </code></pre> <p>rejects:</p> <pre><code>xy: c:\\bob </code></pre>
[ { "answer_id": 307196, "author": "Aaron Palmer", "author_id": 24908, "author_profile": "https://Stackoverflow.com/users/24908", "pm_score": 2, "selected": true, "text": "RegEx=\"^([a-zA-Z]\\:|\\\\\\\\[^\\/\\\\:*?\"<>|]+\\\\[^\\/\\\\:*?\"<>|]+)(\\\\[^\\/\\\\:*?\"<>|]+)+(\\.[^\\/\\\\:*?\"<...
2008/11/20
[ "https://Stackoverflow.com/questions/307183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
307,198
<p>I want to store a URL prefix in an Windows environment variable. The ampersands in the query string makes this troublesome though.</p> <p>For example: I have a URL prefix of <code>http://example.com?foo=1&amp;bar=</code> and want to create a full URL by providing a value for the <code>bar</code> parameter. I then want to launch that URL using the "start" command.</p> <p>Adding quotes around the value for the SET operation is easy enough:</p> <pre><code>set myvar="http://example.com?foo=1&amp;bar=" </code></pre> <p>Windows includes the quotes in the actual value though (thanks Windows!):</p> <pre><code>echo %myvar% "http://example.com?foo=1&amp;bar=true" </code></pre> <p>I know that I can strip quotes away from batch file arguments by using tilde:</p> <pre><code>echo %~1 </code></pre> <p>However, I can't seem to do it to named variables:</p> <pre><code>echo %~myvar% %~myvar% </code></pre> <p>What's the syntax for accomplishing this?</p>
[ { "answer_id": 307218, "author": "wimh", "author_id": 33499, "author_profile": "https://Stackoverflow.com/users/33499", "pm_score": -1, "selected": false, "text": "for /f \"tokens=*\" %i in (%myvar%) do set %myvar%=%~i\n" }, { "answer_id": 307231, "author": "zdan", "autho...
2008/11/20
[ "https://Stackoverflow.com/questions/307198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488/" ]
307,210
<p>I'm doing a PHP site which displays code examples in various languages (C#, PHP, Perl, Ruby, etc.). Are there any PHP functions which add syntax coloring for these and other languages? </p> <p>If not, I would at least like to find that one built-in PHP function which does syntax coloring for PHP code, can't find it anymore. Thanks.</p>
[ { "answer_id": 307228, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 1, "selected": false, "text": "\"<?php\\n$code\\n?>\"" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
307,232
<p>I am very curious about the possibility of providing immutability for java beans (by beans here I mean classes with an empty constructor providing getters and setters for members). Clearly these classes are not immutable and where they are used to transport values from the data layer this seems like a real problem.</p> <p>One approach to this problem has been mentioned here in StackOverflow called "Immutable object pattern in C#" where the object is frozen once fully built. I have an alternative approach and would really like to hear people's opinions on it.</p> <p>The pattern involves two classes Immutable and Mutable where Mutable and Immutable both implement an interface which provides non-mutating bean methods.</p> <p>For example</p> <pre><code>public interface DateBean { public Date getDate(); public DateBean getImmutableInstance(); public DateBean getMutableInstance(); } public class ImmutableDate implements DateBean { private Date date; ImmutableDate(Date date) { this.date = new Date(date.getTime()); } public Date getDate() { return new Date(date.getTime()); } public DateBean getImmutableInstance() { return this; } public DateBean getMutableInstance() { MutableDate dateBean = new MutableDate(); dateBean.setDate(getDate()); return dateBean; } } public class MutableDate implements DateBean { private Date date; public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public DateBean getImmutableInstance() { return new ImmutableDate(this.date); } public DateBean getMutableInstance() { MutableDate dateBean = new MutableDate(); dateBean.setDate(getDate()); return dateBean; } } </code></pre> <p>This approach allows the bean to be constructed using reflection (by the usual conventions) and also allows us to convert to an immutable variant at the nearest opportunity. Unfortunately there is clearly a large amount of boilerplate per bean.</p> <p>I am very interested to hear other people's approach to this issue. (My apologies for not providing a good question, which can be answered rather than discussed :)</p>
[ { "answer_id": 307283, "author": "Michael Rutherfurd", "author_id": 33889, "author_profile": "https://Stackoverflow.com/users/33889", "pm_score": 2, "selected": false, "text": "public interface DateBean {\n public Date getDate();\n}\n\npublic class ImmutableDate implements DateBean {\...
2008/11/20
[ "https://Stackoverflow.com/questions/307232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39476/" ]
307,236
<p>Can any one give me a scripts (HTML/CSS/Javascript) that can reproduce this error on <code>IE 7.0</code>? I am trying to fix this bug in my page where I get this warning but could not exactly found the problem. Line number does not match with the source either. </p> <p>I thought the better approach would be to create a bug and then work on it incrementally rather than making some wild guess!</p>
[ { "answer_id": 307385, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 1, "selected": false, "text": "var blah = {};\nblah.methodWhichDoesntExist(); // <-- error\n" }, { "answer_id": 307431, "author": "nickf", "aut...
2008/11/20
[ "https://Stackoverflow.com/questions/307236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3627/" ]
307,250
<p>I have a field in my form labeled "Name" that will contain both the First &amp; Last name.</p> <p>Our existing dynamic server (to which the form is being POSTed to), expects two separate fields (first name, last name). </p> <p>Can I use Javascript to split the user input into two separate variables before the form is posted to the server? How would I do this?</p>
[ { "answer_id": 307266, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "var yourForm = document.getElementById('yourFormId');\nyourform.onsubmit = new function()\n{\n var nameBox = document.get...
2008/11/20
[ "https://Stackoverflow.com/questions/307250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32154/" ]
307,273
<p>I have the whole MVC-Model set up and use HTML views as templates. But I have german strings in there that I would like to translate to other languages at some point.</p> <p>What is the best way to do this? I know I have to use Zend_Translate, but do I have to implement a single call to a translate function for every word that I have in my view templates?</p>
[ { "answer_id": 308170, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 5, "selected": true, "text": "// setup your translation\n$translate = new Zend_Translate('csv', '/my/path/source-de.csv', 'de');\n$translate->addTr...
2008/11/20
[ "https://Stackoverflow.com/questions/307273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9535/" ]
307,287
<p>I have a question about implementing caching (memoization) using arrays in Haskell. The following pattern works:</p> <pre><code>f = (fA !) where fA = listArray... </code></pre> <p>But this does not (the speed of the program suggests that the array is getting recreated each call or something):</p> <pre><code>f n = (fA ! n) where fA = listArray... </code></pre> <p>Defining fA outside of a where clause (in "global scope") also works with either pattern.</p> <p>I was hoping that someone could point me towards a technical explanation of what the difference between the above two patterns is.</p> <p>Note that I am using the latest GHC, and I'm not sure if this is just a compiler peculiarity or part of the language itself.</p> <p>EDIT: ! is used for array access, so fA ! 5 means fA[5] in C++ syntax. My understanding of Haskell is that (fA !) n would be the same as (fA ! n)...also it would have been more conventional for me to have written "f n = fA ! n" (without the parentheses). Anyway, I get the same behaviour no matter how I parenthesize.</p>
[ { "answer_id": 307399, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 3, "selected": false, "text": "-v4" }, { "answer_id": 308567, "author": "luqui", "author_id": 33796, "author_profile": "https://Stacko...
2008/11/20
[ "https://Stackoverflow.com/questions/307287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
307,292
<p>I have been bitten by a poorly architected solution. It is not thread safe! </p> <p>I have several shared classes and members in the solution, and during development all was cool...<br> BizTalk has sunk my battle ship. </p> <p>We are using a custom BizTalk Adapter to call my assemblies. The Adapter is calling my code and running things in parallel, so I assume it is using multiple threads all under the same AppDomain. </p> <p>What I would like to do is make my code run under its own AppDomain so the shared problems I have will not muck with each other. </p> <p>I have a very simple class that the BizTalk adapter is instantiating then running a Process() method. </p> <p>I would like to create a new AppDomain inside my Process() method, so each time BizTalk spins another thread, it will have its own version of the static classes and methods. </p> <p>BizTalkAdapter Code: </p> <pre><code> // this is inside the BizTalkAdapter and it is calling the Loader class // private void SendMessage(IBaseMessage message, TransactionalTransmitProperties properties) { Stream strm = message.BodyPart.GetOriginalDataStream(); string connectionString = properties.ConnectionString; string msgFileName = message.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties") as string; Loader loader = new Loader(strm, msgFileName, connectionString); loader.Process(); EventLog.WriteEntry("Loader", "Successfully processed: " + msgFileName); } </code></pre> <p>This is the class BizTalk Calls: </p> <pre><code>public class Loader { private string connectionString; private string fileName; private Stream stream; private DataFile dataFile; public Loader(Stream stream, string fileName, string connectionString) { this.connectionString = connectionString; this.fileName = fileName; this.stream = stream; } public void Process() { //***** Create AppDomain HERE ***** // run following code entirely under that domain dataFile = new DataFile(aredStream, fileName, connectionString); dataFile.ParseFile(); dataFile.Save(); // get rid of the AppDomain here... } } </code></pre> <p>FYI: The Loader class is in a seperate DLL from the dataFile class.</p> <p>Any help would be appreciated. I will continue to working on making the code Thread-Safe, but I feel like this could be the "simple" answer. </p> <p>If anyone has any other thought, please throw in.</p> <p>Thank you,<br> Keith</p> <blockquote> <p>Just for completeness.</p> <p>I did find that if I marked the send adapter as "Ordered Delivery" in the "Transport Advanced Options" dialog I was able to avoid the multi-thread issues I was having.</p> <p>I figure this is another possible answer to my problem, but not necessarily to the question.</p> </blockquote>
[ { "answer_id": 307310, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "public class Loader\n{\n private static object SyncRoot = new object();\n private string connectionString;\n p...
2008/11/20
[ "https://Stackoverflow.com/questions/307292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1048/" ]
307,294
<p>SOLVED: Nevermind, the links were visited, and the border definition was missing for visited links (as someone pointed out, thanks). As for the color being first place in the border definition, the snippet comes from the IE Developper Toolbar, this is not directly my code. Anyway, thank you guys !</p> <p>Why does the link in the following snippet does not render underlined with a dashed line, just as expected and as ff would do ?</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Strict//EN"&gt;&lt;META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt; &lt;HTML xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;HEAD&gt;&lt;STYLE&gt; /* Rule 1 of css/style.css */ * { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; FONT-FAMILY: "trebuchet ms", Arial, Helvetica, sans-serif } /* Rule 26 of css/style.css */ #main { PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-BOTTOM: 15px; PADDING-TOP: 15px } /* Rule 12 of css/style.css */ #page { BORDER-RIGHT: #555 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #555 1px solid; PADDING-LEFT: 0px; BACKGROUND: #fff; PADDING-BOTTOM: 0px; MARGIN: 50px auto; BORDER-LEFT: #555 1px solid; WIDTH: 752px; PADDING-TOP: 0px; BORDER-BOTTOM: #555 1px solid } /* Rule 2 of css/style.css */ BODY { BACKGROUND: url(bg.gif) #ebeeff repeat-y center 50% } /* Rule 35 of css/style.css */ #main A:link { COLOR: #437fda; BORDER-BOTTOM: #437fda 1px dashed; TEXT-DECORATION: none } &lt;/STYLE&gt;&lt;/HEAD&gt; &lt;BODY&gt;&lt;DIV id="page"&gt;&lt;DIV id="main"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt; &lt;A href="http://www.immo-brasseurs.com/coords.php?num=37"&gt;Test link &lt;/A&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt; </code></pre>
[ { "answer_id": 307297, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 3, "selected": true, "text": "*{...}" }, { "answer_id": 307301, "author": "Cristian Libardo", "author_id": 16526, "author_...
2008/11/20
[ "https://Stackoverflow.com/questions/307294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39474/" ]
307,304
<p>How do I convert an SQL Server SMALLDATETIME to Unix Timestamp? </p> <p>date was stored as CAST(0x96040474 AS SmallDateTime) in MS Access DB. Data was dumped to SQL and I'm looking to convert those times to Unix Timestamps for MySQL.</p> <p>Thanks AO</p>
[ { "answer_id": 307625, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 0, "selected": false, "text": "smalldatetime" } ]
2008/11/20
[ "https://Stackoverflow.com/questions/307304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
307,305
<p>What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.</p>
[ { "answer_id": 307316, "author": "Rizwan Kassim", "author_id": 35335, "author_profile": "https://Stackoverflow.com/users/35335", "pm_score": 3, "selected": false, "text": "import time, wave, pymedia.audio.sound as sound\nf= wave.open( 'YOUR FILE NAME', 'rb' )\nsampleRate= f.getframerate(...
2008/11/20
[ "https://Stackoverflow.com/questions/307305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
307,313
<p>I am writing an iPhone application, and need to save the state of my application (5K or so).</p> <p>My main worry is data persisting across upgrades. Some of the applications I use clearly got this wrong, and I would prefer not to!</p>
[ { "answer_id": 9675747, "author": "Allison", "author_id": 1166266, "author_profile": "https://Stackoverflow.com/users/1166266", "pm_score": 4, "selected": false, "text": "NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];\n[prefs setObject:@\"TextToSave\" forKey:@\"keyToFindT...
2008/11/20
[ "https://Stackoverflow.com/questions/307313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27074/" ]
307,322
<p>Let's say I have some code like this:<br /></p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;Title&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;?php if (!$someCondition){ die(); } else{ #Do something } ?&gt; &lt;/body&gt; &lt;html&gt; </code></pre> <p>I hope the purpose of this code is straightforward. If a certain condition is met (ie can't connect to database), then the program should die, but otherwise it should execute. My problem arises when the die() function is executed. It stops <strong>right</strong> there, and sends only the first three lines to the browser, but not the last two lines.</p> <p>Is there a funciton that I can use instead of die() so that the php chunks will stop executing, but the static HTML text is still sent through?</p>
[ { "answer_id": 307325, "author": "stalepretzel", "author_id": 1615, "author_profile": "https://Stackoverflow.com/users/1615", "pm_score": 0, "selected": false, "text": "die()" }, { "answer_id": 307336, "author": "J Cooper", "author_id": 38803, "author_profile": "https...
2008/11/20
[ "https://Stackoverflow.com/questions/307322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
307,338
<p>how to create a good plugin engine for standalone executables created with pyInstaller, py2exe or similar tools? </p> <p>I do not have experience with py2exe, but pyInstaller uses an import hook to import packages from it's compressed repository. Of course I am able to import dynamically another compressed repository created with pyInstaller and execute the code - this may be a simple plugin engine.</p> <p>Problems appears when the plugin (this what is imported dynamically) uses a library that is not present in original repository (never imported). This is because import hook is for the original application and searches for packages in original repository - not the one imported later (plugin package repository). </p> <p>Is there an easy way to solve this problem? Maybe there exist such engine?</p>
[ { "answer_id": 307517, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 3, "selected": true, "text": "from distutils.core import setup\nimport py2exe\n\nsetup (name = \"script2compile\",\n console=['script2compile.pyw'],...
2008/11/20
[ "https://Stackoverflow.com/questions/307338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369629/" ]
307,343
<p>Is it possible to forward declare an standard container in a header file? For example, take the following code:</p> <pre><code>#include &lt;vector&gt; class Foo { private: std::vector&lt;int&gt; container_; ... }; </code></pre> <p>I want to be able to do something like this:</p> <pre><code>namespace std { template &lt;typename T&gt; class vector; } class Foo { private: std::vector&lt;int&gt; container_; ... }; </code></pre> <p>Can this be done?</p>
[ { "answer_id": 307349, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 4, "selected": false, "text": "container_" }, { "answer_id": 307408, "author": "Rob Kennedy", "author_id": 33732, "author_profile"...
2008/11/20
[ "https://Stackoverflow.com/questions/307343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
307,348
<p>I need to create a custom control to display bmp images with alpha channel. The background can be painted in different colors and the images have shadows so I need to truly "paint" the alpha channel.</p> <p>Does anybody know how to do it?</p> <p>I also want if possible to create a mask using the alpha channel information to know whether the mouse has been click on the image or on the transparent area.</p> <p>Any kind of help will be appreciated!</p> <p>Thanks.</p> <p>Edited(JDePedro): As some of you have suggested I've been trying to use alpha blend to paint the bitmap with alpha channel. This just a test I've implemented where I load a 32-bit bitmap from resources and I try to paint it using AlphaBlend function:</p> <pre><code>void CAlphaDlg::OnPaint() { CClientDC dc(this); CDC dcMem; dcMem.CreateCompatibleDC(&amp;dc); CBitmap bitmap; bitmap.LoadBitmap(IDB_BITMAP); BITMAP BitMap; bitmap.GetBitmap(&amp;BitMap); int nWidth = BitMap.bmWidth; int nHeight = BitMap.bmHeight; CBitmap *pOldBitmap = dcMem.SelectObject(&amp;bitmap); BLENDFUNCTION m_bf; m_bf.BlendOp = AC_SRC_OVER; m_bf.BlendFlags = 0; m_bf.SourceConstantAlpha = 255; m_bf.AlphaFormat = AC_SRC_ALPHA; AlphaBlend(dc.GetSafeHdc(), 100, 100, nWidth, nHeight, dcMem.GetSafeHdc(), 0, 0,nWidth, nHeight,m_bf); dcMem.SelectObject(pOldBitmap); CDialog::OnPaint(); } </code></pre> <p>This is just a test so I put the code in the OnPaint of the dialog (I also tried the AlphaBlend function of the CDC object).</p> <p>The non-transparent areas are being painted correctly but I get white where the bitmap should be transparent.</p> <p>Any help???</p> <p>This is a screenshot..it's not easy to see but there is a white rectangle around the blue circle: <a href="http://img385.imageshack.us/img385/7965/alphamh8.png">alt text http://img385.imageshack.us/img385/7965/alphamh8.png</a></p> <p>Ok. I got it! I have to pre-multiply every pixel for the alpha value. Someone can suggest the optimized way to do that?</p>
[ { "answer_id": 333542, "author": "mackenir", "author_id": 25457, "author_profile": "https://Stackoverflow.com/users/25457", "pm_score": 1, "selected": false, "text": "R = multiplicationLookup[alpha][R];\nG = multiplicationLookup[alpha][G];\nB = multiplicationLookup[alpha][B];\n" }, {...
2008/11/20
[ "https://Stackoverflow.com/questions/307348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14053/" ]
307,352
<p>I just ran across the following error (and found the solution online, but it's not present in Stack Overflow):</p> <blockquote> <p>(.gnu.linkonce.[stuff]): undefined reference to [method] [object file]:(.gnu.linkonce.[stuff]): undefined reference to `typeinfo for [classname]'</p> </blockquote> <p>Why might one get one of these "undefined reference to typeinfo" linker errors?</p> <p>(Bonus points if you can explain what's going on behind the scenes.)</p>
[ { "answer_id": 307381, "author": "cdleary", "author_id": 3594, "author_profile": "https://Stackoverflow.com/users/3594", "pm_score": 6, "selected": false, "text": "virtual void foo();\n" }, { "answer_id": 307427, "author": "paxdiablo", "author_id": 14860, "author_prof...
2008/11/21
[ "https://Stackoverflow.com/questions/307352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
307,362
<p>I'm trying to get this:</p> <pre><code>//C.h #ifndef C_H #define C_H #include "c.h" class C { public: C(); int function(int, int); }; #endif </code></pre> <p>which is defined in this:</p> <pre><code>//c.cpp #include "c.h" C::C() { } int C::function(int a, int b) { return a * b; } </code></pre> <p>to work in this:</p> <pre><code>//crp.cpp #include &lt;iostream&gt; #include "c.h" void main(void) { C a; std::cout &lt;&lt; a.function(1, 2); } </code></pre> <p>but I get two errors</p> <p>Error: Unresolved external 'C::C()' referenced from C:\C++\CRP.OBJ</p> <p>Error: Unresolved external 'C::function(int, int)' referenced from C:\C++\CRP.OBJ</p> <p>I'm really stuck. Help v. much appreciated! </p> <p>EDIT:</p> <p>Thank you for your replies,</p> <p>I'm using Borland C++ 5.5.1 for Win32, via the command line, I'm not actually sure what a linker is, this is the first time I've tried doing this.</p>
[ { "answer_id": 307378, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "bcc32 -ecrp.exe crp.cpp c.cpp\n" }, { "answer_id": 307383, "author": "Community", "author_id": -1, "...
2008/11/21
[ "https://Stackoverflow.com/questions/307362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
307,364
<p>I have a gallery I quickly coded up for a small site, and under Firefox 3 and Safari 3 works fine. But when I test on my old best friend IE7, it seems to not fire the imageVar.onload = function() { // code here }.. which I want to use to stop the load effect and load the image. </p> <p>Please bear in mind...</p> <ul> <li>I know the thumbnails are just scaled down version of the larger images. When the images are finalised by the client I am going to create proper thumbnails.</li> <li>This is my first attempt to try and get out of procedural JavaScript for the most part.. so please go easy and kindly let me know where my code sucks!</li> </ul>
[ { "answer_id": 307392, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 2, "selected": false, "text": " window.load = function(){ \n //actions to be performed on window load\n }\n\n imageViewer.image.onload = funct...
2008/11/21
[ "https://Stackoverflow.com/questions/307364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
307,365
<p>I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail. The attachment-adding part looks like this:</p> <pre><code>using (MemoryStream pdfStream = new MemoryStream()) { pdfStream.Write(pdfData, 0, pdfData.Length); Attachment a = new Attachment(pdfStream, string.Format("Receipt_{0}_{1}.pdf", jobId, DateTime.UtcNow.ToString("yyyyMMddHHmm"))); msg.Attachments.Add(a); SmtpClient smtp = new SmtpClient(serverName, port); smtp.Credentials = new NetworkCredential(fromEmailName, fromEmailPassword); smtp.Send(msg); } </code></pre> <p>The problem is that the attachment gets corrupted on the other end. I found some discussion of this problem <a href="http://www.systemwebmail.com/faq/4.4.8.aspx" rel="noreferrer">here</a>, however the solution mentioned on that page used System.Web.Mail.MailAttachment, which was made obsolete in .NET 2.0. </p> <p>I've tried changing the TransferEncoding in the Attachment class (which replaces MailAttachment), but had no luck. Has anyone solved this on .NET 2.0?</p>
[ { "answer_id": 307401, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 5, "selected": true, "text": "pdfStream.Seek(0,SeekOrigin.Begin)" }, { "answer_id": 74226856, "author": "Jacob C.", "author_id": 14210...
2008/11/21
[ "https://Stackoverflow.com/questions/307365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24952/" ]
307,367
<p>I have a C project that is built using a makefile, Eclipse constantly warns about "Invalid project path: Duplicate path entries", but I cannot figure out what the hell it wants me to do. I would like to disable this warning and continue with my life.</p> <p>My application compiles and runs fine, with not a single warning except this one. Being a conscientious developer I am keen to fix this problem so I have the warm fuzzies only a clean build can bring.</p>
[ { "answer_id": 12089022, "author": "bouum", "author_id": 1619349, "author_profile": "https://Stackoverflow.com/users/1619349", "pm_score": 0, "selected": false, "text": ".metadata" }, { "answer_id": 27936817, "author": "jww", "author_id": 608639, "author_profile": "ht...
2008/11/21
[ "https://Stackoverflow.com/questions/307367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34879/" ]
307,370
<p>I'm have a ADO DataSet that I'm loading from its XML file via ReadXml. The data and the schema are in separate files.</p> <p>Right now, it takes close to 13 seconds to load this DataSet. I can cut this to 700 milliseconds if I don't read the DataSet's schema and just let ReadXml infer the schema, but then the resulting DataSet doesn't contain any constraints.</p> <p>I've tried doing this:</p> <pre><code>Console.WriteLine("Reading dataset with external schema."); ds.ReadXmlSchema(xsdPath); Console.WriteLine("Reading the schema took {0} milliseconds.", sw.ElapsedMilliseconds); foreach (DataTable dt in ds.Tables) { dt.BeginLoadData(); } ds.ReadXml(xmlPath); Console.WriteLine("ReadXml completed after {0} milliseconds.", sw.ElapsedMilliseconds); foreach (DataTable dt in ds.Tables) { dt.EndLoadData(); } Console.WriteLine("Process complete at {0} milliseconds.", sw.ElapsedMilliseconds); </code></pre> <p>When I do this, reading the schema takes 27ms, and reading the DataSet takes 12000+ milliseconds. And that's the time reported <em>before</em> I call EndLoadData on all the DataTables.</p> <p>This is not an enormous amount of data - it's about 1.5mb, there are no nested relations, and all of the tables contain two or three columns of 6-30 characters. The only thing I can figure that's different if I read the schema up front is that the schema includes all of the unique constraints. But BeginLoadData is supposed to turn constraints off (as well as change notification, etc.). So that shouldn't apply here. (And yes, I've tried just setting EnforceConstraints to false.)</p> <p>I've read many reports of people improving the load time of DataSets by reading the schema first instead of having the object infer the schema. In my case, inferring the schema makes for a process that's about 20 times faster than having the schema provided explicitly.</p> <p>This is making me a little crazy. This DataSet's schema is generated off of metainformation, and I'm tempted to write a method that creates it programatically and just deseralizes it with an XmlReader. But I'd much prefer not to.</p> <p>What am I missing? What else can I do to improve the speed here?</p>
[ { "answer_id": 10856773, "author": "Jon", "author_id": 1431550, "author_profile": "https://Stackoverflow.com/users/1431550", "pm_score": 1, "selected": false, "text": "void create_files()\n {\n //create text file with data\n StreamWriter sr = new StreamWriter(\"plain_tex...
2008/11/21
[ "https://Stackoverflow.com/questions/307370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19403/" ]
307,389
<p>Is there a firefox plugin or something similar I can use to validate that my html output has properly closed tags?</p>
[ { "answer_id": 307412, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 1, "selected": false, "text": "alt" }, { "answer_id": 307461, "author": "Community", "author_id": -1, "author_profile": "https://Stackove...
2008/11/21
[ "https://Stackoverflow.com/questions/307389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7883/" ]
307,391
<p>I am using an ASP.NET <code>ModalPopupExtender</code> on a page and would like to prevent the dialog from hiding when the user presses the ok button in certain conditions. But I can't seem to find a way.</p> <p>What I am looking for is something like this</p> <pre><code>ajax:ModalPopupExtender ... OnOkScript=&quot;return confirm('You sure?')&quot; ... </code></pre> <p>if confirm is false, then the modal dialog doesn't disappear.</p>
[ { "answer_id": 307412, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 1, "selected": false, "text": "alt" }, { "answer_id": 307461, "author": "Community", "author_id": -1, "author_profile": "https://Stackove...
2008/11/21
[ "https://Stackoverflow.com/questions/307391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/698/" ]
307,411
<p>I'm new to jQuery, and I'm totally struggling with using jQuery UI's <code>sortable</code>.</p> <p>I'm trying to put together a page to facilitate grouping and ordering of items.</p> <p>My page has a list of groups, and each group contains a list of items. I want to allow users to be able to do the following: </p> <blockquote> <ol> <li>Reorder the groups </li> <li>Reorder the items within the groups </li> <li>Move the items between the groups</li> </ol> </blockquote> <p>The first two requirements are no problem. I'm able to sort them just fine. The problem comes in with the third requirement. I just can't connect those lists to each other. Some code might help. Here's the markup. </p> <pre><code>&lt;ul id="groupsList" class="groupsList"&gt; &lt;li id="group1" class="group"&gt;Group 1 &lt;ul id="groupItems1" class="itemsList"&gt; &lt;li id="item1-1" class="item"&gt;Item 1.1&lt;/li&gt; &lt;li id="item1-2" class="item"&gt;Item 1.2&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="group2" class="group"&gt;Group 2 &lt;ul id="groupItems2" class="itemsList"&gt; &lt;li id="item2-1" class="item"&gt;Item 2.1&lt;/li&gt; &lt;li id="item2-2" class="item"&gt;Item 2.2&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="group3" class="group"&gt;Group 3 &lt;ul id="groupItems3" class="itemsList"&gt; &lt;li id="item3-1" class="item"&gt;Item 3.1&lt;/li&gt; &lt;li id="item3-2" class="item"&gt;Item 3.2&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I was able to sort the lists by putting <code>$('#groupsList').sortable({});</code> and <code>$('.itemsList').sortable({});</code> in the <code>document ready function</code>. I tried using the <code>connectWith</code> option for <code>sortable</code> to make it work, but I failed spectacularly. What I'd like to do is have the every <code>groupItemsX</code> list connected to every <code>groupItemsX</code> list but itself. How should I do that?</p> <hr> <p>I was thinking I needed to specifically not connect a list to itself less there be some sort of circular reference. Granted, I'm not working with Excel, but it seemed like that could cause some sort of never ending recursion that would cause a stack overflow or something. Hmm. Sorry for the pun. Couldn't help myself. </p> <p>Anyway, I was trying to do something like this, and it wasn't working: </p> <pre><code>$('.groupsList').sortable(); // worked great $('.groupsList').each( function () { $(this).sortable( { connectWith: ['.groupsList':not('#'+ $(this).attr('id') )]; }); }); </code></pre> <p>I'm sure I've completely mangled the syntax there, and I suppose that's the reason I had to ask the question in the first place. Is it even necessary or helpful performance-wise to filter the current item out of the list?</p> <p>Both of the answers provided by Adam and JimmyP worked in IE (although they behave really oddly in FireFox, overwriting list items when you try to re-sort). I'll accept one of your answers and vote on the other, but if you have ideas/ suggestions about the filtering, I'd like to hear it.</p>
[ { "answer_id": 310508, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 6, "selected": true, "text": "connectWith" }, { "answer_id": 311159, "author": "James", "author_id": 21677, "author_profile": "...
2008/11/21
[ "https://Stackoverflow.com/questions/307411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1245/" ]
307,423
<p>I have the following two files and would like the second to extend the first:</p> <ol> <li>wwwroot\site\application.cfc</li> <li>wwwroot\site\dir\application.cfc</li> </ol> <p>However, when I go to declare the component for the second file, I'm not sure what to put in the extends attribute. <strong>My problem is that several dev sites (with a shared SVN repository) are running off the same instance of ColdFusion</strong>, so I can't just create a mapping in the CF admin like so:</p> <pre><code>&lt;cfcomponent extends="site.application"&gt; </code></pre> <p>However, ColdFusion doesn't like:</p> <pre><code>&lt;cfcomponent extends="..application"&gt; </code></pre> <p>or any dynamic input like:</p> <pre><code>&lt;cfcomponent extends="#expandpath('..').#application"&gt; </code></pre> <p>Creating a runtime mapping (<a href="https://stackoverflow.com/questions/287187/extend-a-cfc-using-a-relative-path">like here</a>) doesn't seem possible either. Creating it in the base application.cfc is useless because that code hasn't yet executed by the time the inheriting cfc is being declared; and I can't create the mapping before the inheriting component is defined because there isn't yet an application to attach it to.</p> <p>Is there any way I can reference the parent directory to accomplish my extends?</p> <p>Edit to clarify: The ApplicationProxy solution doesn't work because of the bolded text above. Right now, as a workaround, we're simply not checking the \dir\application.cfc into SVN so that each developer can keep a version that extends his/her own root application.cfc. Obviously, this is not ideal.</p>
[ { "answer_id": 307441, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 4, "selected": false, "text": "<cfcomponent>\n\n <cfset this.name = \"cf7app\" />\n <cfset this.sessionmanagement = true />\n\n</cfcomponent>\...
2008/11/21
[ "https://Stackoverflow.com/questions/307423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3420/" ]
307,433
<p>Working to get DateTimes for any time zone. I'm using DateTimeOffset, and a string, and an XmlElement attribute. When I do, I get the following error:</p> <blockquote> <p>[InvalidOperationException: 'dateTime' is an invalid value for the XmlElementAttribute.DataType property. dateTime cannot be converted to System.String.]<br> System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter) +450</p> <p>[InvalidOperationException: There was an error reflecting type 'System.String'.]<br> System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter) +1621<br> System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +8750<br> System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, String ns, RecursionLimiter limiter) +139<br> System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter) +1273</p> <p>[InvalidOperationException: There was an error reflecting property 'creationTimeX'.] ...</p> </blockquote> <p>Code:</p> <pre><code> [System.Xml.Serialization.XmlElement(ElementName = "creationTime", DataType="dateTime")] public string creationTimeX { get { return this.creationTimeField.ToString("yyyy-MM-ddTHH:mm:sszzz"); } set { DateTimeOffset.TryParse(value, out this.creationTimeField); } } [System.Xml.Serialization.XmlIgnoreAttribute()] public System.DateTimeOffset creationTime { get { return this.creationTimeField; } set { this.creationTimeField = value; } } </code></pre>
[ { "answer_id": 307453, "author": "user35559", "author_id": 35559, "author_profile": "https://Stackoverflow.com/users/35559", "pm_score": 0, "selected": false, "text": "creationTimeX" }, { "answer_id": 310162, "author": "Asher", "author_id": 38265, "author_profile": "h...
2008/11/21
[ "https://Stackoverflow.com/questions/307433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36627/" ]
307,437
<p>I have two directories in the same parent directory. Call the parent directory <strong>base</strong> and the children directories <strong>alpha</strong> and <strong>bravo</strong>. I want to replace <strong>alpha</strong> with <strong>bravo</strong>. The simplest method is:</p> <pre><code>rm -rf alpha mv bravo alpha </code></pre> <p>The mv command is atomic, but the rm -rf is not. Is there a simple way in bash to atomically replace <strong>alpha</strong> with <strong>bravo</strong>? If not, is there a complicated way?</p> <p>ADDENDUM:</p> <p>By the by, it's not an insurmountable problem if the directory doesn't exist for a short period. There's only one place that tries to access alpha, and it checks if alpha exists before doing anything critical. If not, it gives an error message. But it would be nice if there was a way to do this. :) Maybe there's some way to modify the inodes directly, or something...</p>
[ { "answer_id": 307447, "author": "Chris Charabaruk", "author_id": 5697, "author_profile": "https://Stackoverflow.com/users/5697", "pm_score": 0, "selected": false, "text": "mv alpha delme\nmv bravo alpha\nrm -rf delme\n" }, { "answer_id": 307450, "author": "paxdiablo", "a...
2008/11/21
[ "https://Stackoverflow.com/questions/307437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20903/" ]
307,438
<p>In the footer of my page, I would like to add something like "last updated the xx/xx/200x" with this date being the last time a certain mySQL table has been updated.</p> <p>What is the best way to do that? Is there a function to retrieve the last updated date? Should I access to the database every time I need this value?</p>
[ { "answer_id": 307488, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 9, "selected": true, "text": "information_schema" }, { "answer_id": 3227579, "author": "Radu Maris", "author_id": 207603, "author_profi...
2008/11/21
[ "https://Stackoverflow.com/questions/307438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39474/" ]
307,445
<p>I have a 2D image randomly and sparsely scattered with pixels.<br> given a point on the image, I need to find the distance to the closest pixel that is not in the background color (black).<br> What is the fastest way to do this? </p> <p>The only method I could come up with is building a kd-tree for the pixels. but I would really want to avoid such expensive preprocessing. also, it seems that a kd-tree gives me more than I need. I only need the distance to something and I don't care about what this something is. </p>
[ { "answer_id": 320735, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "r^2 = dx^2 + dy^2\n" }, { "answer_id": 3381634, "author": "XCS", "author_id": 407650, "author_profile": ...
2008/11/21
[ "https://Stackoverflow.com/questions/307445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611/" ]
307,463
<p>What's the general consensus?</p> <p>If you need to change the database after a given action, do you use an observer pattern and let the framework / application handle the update for you? Or do you bypass the application and delegate the update to a database trigger?</p> <p>Obviously the trigger is faster, but is it worth it?</p>
[ { "answer_id": 307487, "author": "Andre Gallo", "author_id": 14401, "author_profile": "https://Stackoverflow.com/users/14401", "pm_score": 2, "selected": false, "text": " /// <summary>\n /// Sends changes that were made to retrieved objects to the underlying database, \n /// and...
2008/11/21
[ "https://Stackoverflow.com/questions/307463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38354/" ]
307,486
<p>I want to create a unique id but <code>uniqid()</code> is giving something like <code>'492607b0ee414'</code>. What i would like is something similar to what tinyurl gives: <code>'64k8ra'</code>. The shorter, the better. The only requirements are that it should not have an obvious order and that it should look prettier than a seemingly random sequence of numbers. Letters are preferred over numbers and ideally it would not be mixed case. As the number of entries will not be that many (up to 10000 or so) the risk of collision isn't a huge factor.</p> <p>Any suggestions appreciated.</p>
[ { "answer_id": 307617, "author": "RJHunter", "author_id": 39223, "author_profile": "https://Stackoverflow.com/users/39223", "pm_score": 2, "selected": false, "text": "uniqid()" }, { "answer_id": 307773, "author": "lpfavreau", "author_id": 35935, "author_profile": "htt...
2008/11/21
[ "https://Stackoverflow.com/questions/307486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6037/" ]
307,494
<p>I would like to do something like the following:</p> <pre><code>def add(a, b): #some code def subtract(a, b): #some code operations = [add, subtract] operations[0]( 5,3) operations[1](5,3) </code></pre> <p>In python, is it possible to assign something like a function pointer?</p>
[ { "answer_id": 307622, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 3, "selected": false, "text": "def the_simple_way(a, b):\n # blah blah\n\ndef the_complicated_way(a, b):\n # blah blah\n\ndef foo(way):\n ...
2008/11/21
[ "https://Stackoverflow.com/questions/307494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64/" ]
307,495
<p>in Web 2.0 applications many users usually want to stay logged in ('remember me' flag) and on the other hand their cookie can give access to very private data. Is there a way to prevent that somebody who steals the cookie - directly from the computer or via sniffing - can use the cookie to get access to the user's data? Always HTTPS is not an option.</p> <p>Thanks, Bernd</p> <p>[Edit] Connect the IP address to the cookie is not an option either.</p>
[ { "answer_id": 309276, "author": "mjmcinto", "author_id": 28660, "author_profile": "https://Stackoverflow.com/users/28660", "pm_score": 0, "selected": false, "text": "Page.Request.UserHostName\n" } ]
2008/11/21
[ "https://Stackoverflow.com/questions/307495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
307,500
<p>I have a table structure that looks like:</p> <pre><code>&lt;table&gt; &lt;tr id="row1"&gt; &lt;td&gt; &lt;div&gt;row 1 content1&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;row 1 content2&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;row 1 content3&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="row2"&gt; &lt;td&gt; &lt;div&gt;row 2 content1&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;row 2 content2&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;row 2 content3&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="row3"&gt; &lt;td&gt; &lt;div&gt;row 3 content1&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;row 3 content2&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;row 3 content3&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Using jQuery I am trying to select the DIV in the second cell of the third row. I tried the following (amongst other things):</p> <pre><code>var d = $('#row3').children(':eq(1)').children(':eq(0)'); </code></pre> <p>What I get back is an array with a single element (the DIV I'm after) and I have to then access using d[0]. Why is jQuery returning a single element array, I thought using the selector above would return the DIV element directly?</p> <hr> <p><strong><a href="https://stackoverflow.com/questions/307500/how-do-i-select-an-element-in-jquery#307509">@Shog9</a></strong> - Duh...Ok a light just switched on in my brain, I get it now. Cheers.</p>
[ { "answer_id": 307509, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 6, "selected": true, "text": "$(\"selector\").each(function()\n{\n this.style.backgroundColor = \"red\";\n});\n" }, { "answer_id": 6269297, "auth...
2008/11/21
[ "https://Stackoverflow.com/questions/307500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]