qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
542,888
<p>Is it possible to change the styling of iPhone native buttons? For example, I'd like to use a smaller font size for part of the button text, and larger for another - something like</p> <pre><code>&lt;small&gt;pick a&lt;/small&gt;&lt;big&gt;color&lt;/big&gt; </code></pre> <p>I'd also like to use buttons that form a...
[ { "answer_id": 542927, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": true, "text": "<p>I don't think you can do it easily. You'll probably have to subclass <a href=\"https://developer.apple.com/iphone...
2009/02/12
[ "https://Stackoverflow.com/questions/542888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13055/" ]
Is it possible to change the styling of iPhone native buttons? For example, I'd like to use a smaller font size for part of the button text, and larger for another - something like ``` <small>pick a</small><big>color</big> ``` I'd also like to use buttons that form a right-arrow shape instead of being rectangular. S...
I don't think you can do it easily. You'll probably have to subclass [`UISegmentedControl`](https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UISegmentedControl_Class/Reference/UISegmentedControl.html) and override a bunch of methods. To get differently sized fonts on the button text, you'll have...
542,890
<p>I currently maintain an application that's written in Flash 8 (AS2) which is used to embed and control some auto-generated SWFs. The auto-generated SWFs are also Flash 8 (actually, they work at least in 7, possibly even older), so my current app is able to directly reference variables and functions within the embed...
[ { "answer_id": 543024, "author": "Assaf Lavie", "author_id": 11208, "author_profile": "https://Stackoverflow.com/users/11208", "pm_score": 0, "selected": false, "text": "<p>Could the two communicate through a server (i.e. a mediator)?</p>\n" }, { "answer_id": 543859, "author"...
2009/02/12
[ "https://Stackoverflow.com/questions/542890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1409/" ]
I currently maintain an application that's written in Flash 8 (AS2) which is used to embed and control some auto-generated SWFs. The auto-generated SWFs are also Flash 8 (actually, they work at least in 7, possibly even older), so my current app is able to directly reference variables and functions within the embedded ...
Not sure I get exactly how the application works so excuse me if I'm wrong. If the flex instance must load the AVM1 proxy wouldn't it be possible to inject a flash-var via the URL containing a generated ID for the LocalConnection to use ? In addition to your comment, just added how to send variables to the AVM1 movie....
542,895
<p>I'm having trouble applying a patch to my source tree, and it's not the usual <code>-p</code> stripping problem. <code>patch</code> is able to find the file to patch.</p> <p>Specifically, my question is how to read / interpret the <code>.rej</code> files <code>patch</code> creates when it fails on a few hunks. Most...
[ { "answer_id": 543045, "author": "Bodo Thiesen", "author_id": 2179300, "author_profile": "https://Stackoverflow.com/users/2179300", "pm_score": 5, "selected": true, "text": "<p>A simple example:</p>\n\n<pre><code>$ echo -e \"line 1\\nline 2\\nline 3\" &gt; a\n$ sed -e 's/2/b/' &lt;a &gt;...
2009/02/12
[ "https://Stackoverflow.com/questions/542895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm having trouble applying a patch to my source tree, and it's not the usual `-p` stripping problem. `patch` is able to find the file to patch. Specifically, my question is how to read / interpret the `.rej` files `patch` creates when it fails on a few hunks. Most discussions of `patch`/`diff` I have seen don't inclu...
A simple example: ``` $ echo -e "line 1\nline 2\nline 3" > a $ sed -e 's/2/b/' <a >b $ sed -e 's/2/c/' <a >c $ diff a b > ab.diff $ patch c < ab.diff $ cat c.rej *************** *** 2 - line 2 --- 2 ----- + line b ``` As you can see: The old file contains line 2 and the new file *should* contain line b. However, it ...
542,904
<p>I have a problem writing a SQL statement for both Oracle and MS SQL server. I'd like to write the SQL so that it works in both. I don't want to have to mess around with setting a database type variable and switching</p> <p>I have a column of course names that have values like this:</p> <blockquote> <p>9RA923.2008W...
[ { "answer_id": 542924, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>Can you cast it to a numeric and then take just the decimal part?</p>\n" }, { "answer_id": 542959, "aut...
2009/02/12
[ "https://Stackoverflow.com/questions/542904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28351/" ]
I have a problem writing a SQL statement for both Oracle and MS SQL server. I'd like to write the SQL so that it works in both. I don't want to have to mess around with setting a database type variable and switching I have a column of course names that have values like this: > > 9RA923.2008W > > > 1223.200710 > >...
Looking at [this link](http://sqlzoo.net/lfun), I do not see a standard way to achieve what you want to do. ``` ORACLE uses: INSTR SQL SERVER uses: PATINDEX, CHARINDEX ORACLE uses: SUBSTR SQL SERVER uses: SUBSTRING ``` I could not think of a common method to obtain a character position. A *VIEW* is probably the e...
542,908
<p>Can you please convert this code from C# to Python to be run on IronPython?</p> <p>I don’t have any experience with Python.</p> <pre><code>using System; using Baz; namespace ConsoleApplication { class Program { static void Main() { Portal foo = new Portal("Foo"); Agent bar = new Agent...
[ { "answer_id": 542939, "author": "fuentesjr", "author_id": 10708, "author_profile": "https://Stackoverflow.com/users/10708", "pm_score": 2, "selected": false, "text": "<p>I think it would suit you best if you take a look at the following links:</p>\n\n<p><a href=\"http://www.learningpyth...
2009/02/12
[ "https://Stackoverflow.com/questions/542908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61976/" ]
Can you please convert this code from C# to Python to be run on IronPython? I don’t have any experience with Python. ``` using System; using Baz; namespace ConsoleApplication { class Program { static void Main() { Portal foo = new Portal("Foo"); Agent bar = new Agent("Bar"); foo...
Instantiation doesn't require a type definition. Methods called the same, assign delegates directly. The previous answer is absolutely right, you'll need a **lot** more context in order to "convert" a C# application to Python; it's more than just syntax. ``` foo = Portal("Foo") bar = Agent("bar") foo.Connect("ip", 1...
542,929
<p>I'm getting burned repeatedly by unmatched parentheses while writing python code in vim. I like how they're handled for C code - vim highlights in red all of the curly braces following the unmatched paren. I looked at the <code>c.vim</code> syntax file briefly to try to understand it, but the section that handles ...
[ { "answer_id": 543521, "author": "Whaledawg", "author_id": 23829, "author_profile": "https://Stackoverflow.com/users/23829", "pm_score": 2, "selected": false, "text": "<p>Stop gap solution:</p>\n\n<pre><code>:imap ( ()&lt;C-[&gt;i\n</code></pre>\n\n<p>This will make it so every time you ...
2009/02/12
[ "https://Stackoverflow.com/questions/542929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46821/" ]
I'm getting burned repeatedly by unmatched parentheses while writing python code in vim. I like how they're handled for C code - vim highlights in red all of the curly braces following the unmatched paren. I looked at the `c.vim` syntax file briefly to try to understand it, but the section that handles bracket errors i...
If I understand correctly and you are trying to look at non-matching parenthesis in C code (that was generated in python), I would recommend you install rainbow.vim from [Dr Chip's Site](http://www.drchip.org/astronaut/vim/#RAINBOW). This will highlight braces in different colours depending on the levels of indentation...
542,937
<p>I have some SP that takes year and month:</p> <pre><code>Create PROCEDURE Report( @targetYear int, @targetMonth int ) </code></pre> <p>And querying it with:</p> <pre><code>select sum(col) where year(dateTime) = @targetYear and month(dateTime) = @targetMonth </code></pre> <p>Then I have the same thing for...
[ { "answer_id": 542955, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<pre><code>SELECT sum(col) \nFROM [yourtable]\nWHERE year(dateTime) = @TargetYear \n AND (@targetMonth &lt; 0 OR mo...
2009/02/12
[ "https://Stackoverflow.com/questions/542937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have some SP that takes year and month: ``` Create PROCEDURE Report( @targetYear int, @targetMonth int ) ``` And querying it with: ``` select sum(col) where year(dateTime) = @targetYear and month(dateTime) = @targetMonth ``` Then I have the same thing for year only ``` Create PROCEDURE Report( @tar...
I like Joel's answer except his won't work if you pass in a zero as the month. You will want @targetMonth=0 for example: ``` SELECT sum(col) WHERE year(dateTime) = @TargetYear AND (@targetMonth = 0 OR month(dateTime) = @targetMonth) ```
542,938
<p>For example, given two dates in input boxes:</p> <pre><code>&lt;input id=&quot;first&quot; value=&quot;1/1/2000&quot;/&gt; &lt;input id=&quot;second&quot; value=&quot;1/1/2001&quot;/&gt; &lt;script&gt; alert(datediff(&quot;day&quot;, first, second)); // what goes here? &lt;/script&gt; </code></pre> <p>How do I ge...
[ { "answer_id": 543043, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 3, "selected": false, "text": "<p>What about using <a href=\"http://docs.jquery.com/UI/Datepicker/%24.datepicker.formatDate\" rel=\"noreferrer\">for...
2009/02/12
[ "https://Stackoverflow.com/questions/542938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29/" ]
For example, given two dates in input boxes: ``` <input id="first" value="1/1/2000"/> <input id="second" value="1/1/2001"/> <script> alert(datediff("day", first, second)); // what goes here? </script> ``` How do I get the number of days between two dates in JavaScript?
Here is a **quick and dirty** implementation of `datediff`, as a proof of concept to solve the problem as presented in the question. It relies on the fact that you can get the elapsed milliseconds between two dates by subtracting them, which coerces them into their primitive number value (milliseconds since the start o...
542,961
<p>I want to know how gmail implements its <strong>add link to mail</strong> function - is it a div which changing it's display? Is it another layer? Or is it something else?</p> <p>Thanks in advance,</p> <p>oz radiano.</p>
[ { "answer_id": 543089, "author": "Matt Briggs", "author_id": 10771, "author_profile": "https://Stackoverflow.com/users/10771", "pm_score": 0, "selected": false, "text": "<p>Asynchronous javascript server callbacks with DOM manipulation. More then just swapping out the html in one big div...
2009/02/12
[ "https://Stackoverflow.com/questions/542961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to know how gmail implements its **add link to mail** function - is it a div which changing it's display? Is it another layer? Or is it something else? Thanks in advance, oz radiano.
Are you talking about one of these? ### Add link form [GMail Add Link 1 http://www.kalleload.net/uploads/thumbnails/bxpwxqpauzxe.png](http://www.kalleload.net/uploads/jrwddejjnheh.png) ### Floating link toolbar [GMail Add Link 2 http://www.kalleload.net/uploads/thumbnails/rrdkcg\_tuqjfypvmlra.png](http://www.kallel...
542,964
<p>The following (sanitized) code sometimes produces these errors: </p> <blockquote> <p>Cannot drop the table 'database.dbo.Table', because it does not exist or you do not have permission.<br> There is already an object named 'Table' in the database.</p> </blockquote> <pre><code>begin transaction if exists...
[ { "answer_id": 543002, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 3, "selected": false, "text": "<p>Can I ask why your doing this first? You should really consider using temporary tables or come up with another soluti...
2009/02/12
[ "https://Stackoverflow.com/questions/542964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37685/" ]
The following (sanitized) code sometimes produces these errors: > > Cannot drop the table 'database.dbo.Table', because it does not exist or you do not have permission. > > There is already an object named 'Table' in the database. > > > ``` begin transaction if exists (select 1 from database.Sys.Tables...
In what part of the code are you preventing multiple accesses to this resource? ``` begin transaction if exists (select 1 from database.Sys.Tables where name ='Table') begin drop table database.dbo.Table end Select top 3000 * into database.dbo.Table from OtherTable commit ``` Begin trans...
542,973
<p>I'd like to have a handler fire whenever the user scrolls, but I don't want it to happen when the browser scrolls on behalf of the user. For example, the document below scrolls itself as part of onload. This fires my onscroll handler, but I don't want it to. Even if I remove the onload, there's still a problem: if t...
[ { "answer_id": 543023, "author": "DMCS", "author_id": 52087, "author_profile": "https://Stackoverflow.com/users/52087", "pm_score": 0, "selected": false, "text": "<p>How about adding the <code>onscroll</code> event during the <code>document.onReady</code> event, instead of inline on the ...
2009/02/12
[ "https://Stackoverflow.com/questions/542973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91385/" ]
I'd like to have a handler fire whenever the user scrolls, but I don't want it to happen when the browser scrolls on behalf of the user. For example, the document below scrolls itself as part of onload. This fires my onscroll handler, but I don't want it to. Even if I remove the onload, there's still a problem: if the ...
How about setting a (boolean) flag whenever you move the screen programmatically, and unsetting again, when the move is finished? Then your scroll-listener would first check against that flag, and make its actions based on that?
542,987
<p>Let's say you have a small calculator program that takes numbers and an operator to perform on those numbers as input, then prints out the result of applying the specified operation. So if you input "4 + 5" it will print out "9". Simple, right? Well what I want to be able to write is something this:</p> <pre><code>...
[ { "answer_id": 542996, "author": "joeforker", "author_id": 36330, "author_profile": "https://Stackoverflow.com/users/36330", "pm_score": 2, "selected": false, "text": "<p>If you really wanted to do this, you would need the standard <code>operator</code> module. See also <a href=\"http://...
2009/02/12
[ "https://Stackoverflow.com/questions/542987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Let's say you have a small calculator program that takes numbers and an operator to perform on those numbers as input, then prints out the result of applying the specified operation. So if you input "4 + 5" it will print out "9". Simple, right? Well what I want to be able to write is something this: ``` a, op, b = raw...
Basically no, you will at least need to have a dictionary or function to map operator characters to their implementations. It's actually a little more complicated than that, since not all operators take the form `a [op] b`, so in general you'd need to do a bit of parsing; see <https://docs.python.org/library/operator.h...
542,994
<p>I'm using an Infragistics grid on a form and am handling multiple client-side events on the cells (e.g. cell click, before cell edit, before cell update, etc).</p> <p>On the cell click event, I'm spawning a secondary window (successfully) as follows:</p> <pre><code>var convChartWindow = window.open(&quot;conversionc...
[ { "answer_id": 543031, "author": "mkoryak", "author_id": 26188, "author_profile": "https://Stackoverflow.com/users/26188", "pm_score": 1, "selected": true, "text": "<p>i dont know what infragistics is. ill assume its some framework over which you have no control. if i were you i would tr...
2009/02/12
[ "https://Stackoverflow.com/questions/542994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6624/" ]
I'm using an Infragistics grid on a form and am handling multiple client-side events on the cells (e.g. cell click, before cell edit, before cell update, etc). On the cell click event, I'm spawning a secondary window (successfully) as follows: ``` var convChartWindow = window.open("conversioncharts/" + currentCell.ge...
i dont know what infragistics is. ill assume its some framework over which you have no control. if i were you i would try the following: 1) set a timeout to take focus back to the window after 1000 ms, or set a timeout loop to set focus to the window you need. this is a hack. 2) figure out what functions fire the ev...
542,995
<p>I think this is a dumb question but I could not find it on php. Why is a + with the = in the following code:</p> <pre><code>function calculateRanking() { $created = $this-&gt;getCreated(); $diff = $this-&gt;getTimeDifference($created, date('F d, Y h:i:s A')); $time = $diff['days'] * 24; $time += $...
[ { "answer_id": 543005, "author": "DMCS", "author_id": 52087, "author_profile": "https://Stackoverflow.com/users/52087", "pm_score": 4, "selected": false, "text": "<pre class=\"lang-php prettyprint-override\"><code>$time += $diff['hours'];\n</code></pre>\n\n<p>is the same as saying</p>\n\...
2009/02/12
[ "https://Stackoverflow.com/questions/542995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2170954/" ]
I think this is a dumb question but I could not find it on php. Why is a + with the = in the following code: ``` function calculateRanking() { $created = $this->getCreated(); $diff = $this->getTimeDifference($created, date('F d, Y h:i:s A')); $time = $diff['days'] * 24; $time += $diff['hours']; $...
It's adding all those values to time. ``` something += somethingelse ``` is a shortcut for ``` something = something + somethingelse ``` -Adam
543,000
<p>Is it possible to set up a mysql trigger that fires back the id number of that record when ever there is an insert into the database AND how do i capture that using php?</p>
[ { "answer_id": 543040, "author": "user64718", "author_id": 64718, "author_profile": "https://Stackoverflow.com/users/64718", "pm_score": 1, "selected": false, "text": "<p>I'm not really sure what you're asking. Are you wanting to insert a row into the database and get the id it was assi...
2009/02/12
[ "https://Stackoverflow.com/questions/543000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16458/" ]
Is it possible to set up a mysql trigger that fires back the id number of that record when ever there is an insert into the database AND how do i capture that using php?
Unless I don't fully understand your question, you don't need a trigger for this - just use the "last inserted ID" functionality of your database driver. Here's an example using the basic mysql driver in PHP. ``` <?php $db = mysql_connect( 'localhost', 'user', 'pass' ); $result = mysql_query( "insert into table (co...
543,026
<p>I have been using gridview since a long time. I have a "cant live with you and cant live without you" relationship with it.</p> <p>The idea of Edits, inserts and deletes from within the grid is great but having to do something like</p> <pre><code>var sometext = ((TextBox)editRow.FindControl("tbSomeText")).Text; </...
[ { "answer_id": 543042, "author": "Barbaros Alp", "author_id": 51734, "author_profile": "https://Stackoverflow.com/users/51734", "pm_score": 2, "selected": false, "text": "<p>I always use repeater control instead of others. Because i feel free with it. I build up the html by myself and ca...
2009/02/12
[ "https://Stackoverflow.com/questions/543026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37494/" ]
I have been using gridview since a long time. I have a "cant live with you and cant live without you" relationship with it. The idea of Edits, inserts and deletes from within the grid is great but having to do something like ``` var sometext = ((TextBox)editRow.FindControl("tbSomeText")).Text; ``` just seems very u...
If you are trying to make a basic CRUD website, have a look at [ASP.NET 3.5 Dynamic Data](http://www.asp.net/learn/3.5-SP1/) which is a great website to add as a pure data access website with CRUD ability. However, its extremely customizable. Gridview has its advantages and I used to love it in the .Net 2.0 times abou...
543,047
<p>How do I read and write a file using a file format which is readable by a database server, in vb2008?</p> <p>I have very little experience working with databases, and I can't seem to find any tutorials which don't involve some type of server as a middle-man.</p>
[ { "answer_id": 543076, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 0, "selected": false, "text": "<p>If you don't want a server, use SQLite. There are .NET bindings that work quite nicely.</p>\n\n<p>Reading and ...
2009/02/12
[ "https://Stackoverflow.com/questions/543047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52239/" ]
How do I read and write a file using a file format which is readable by a database server, in vb2008? I have very little experience working with databases, and I can't seem to find any tutorials which don't involve some type of server as a middle-man.
It's really going to depend on which type of database files you are working with. If you have an Access Database file, you can open a connection to the database with the following code. ``` Dim DBConn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDBFile.mdb;") ```
543,049
<p>I want to use JDOM to read in an XML file, then use XPath to extract data from the JDOM Document. It creates the Document object fine, but when I use XPath to query the Document for a List of elements, I get nothing.</p> <p>My XML document has a default namespace defined in the root element. The funny thing is, w...
[ { "answer_id": 543120, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 6, "selected": true, "text": "<p><strong>XPath 1.0</strong> doesn't support the concept of a default namespace (<strong>XPath 2.0</strong> does).\n...
2009/02/12
[ "https://Stackoverflow.com/questions/543049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13379/" ]
I want to use JDOM to read in an XML file, then use XPath to extract data from the JDOM Document. It creates the Document object fine, but when I use XPath to query the Document for a List of elements, I get nothing. My XML document has a default namespace defined in the root element. The funny thing is, when I remove...
**XPath 1.0** doesn't support the concept of a default namespace (**XPath 2.0** does). Any unprefixed tag is always assumed to be part of the no-name namespace. When using **XPath 1.0** you need something like this: ``` public static void main(String args[]) throws Exception { SAXBuilder builder = new SAXBuilde...
543,069
<p>Is there something like the java 'glasspane' in as3?</p> <p><em>The glass pane is useful when you want to be able to catch events or paint over an area that already contains one or more components. For example, you can deactivate mouse events for a multi-component region by having the glass pane intercept the event...
[ { "answer_id": 543097, "author": "James Hay", "author_id": 47339, "author_profile": "https://Stackoverflow.com/users/47339", "pm_score": 3, "selected": true, "text": "<p>if you set </p>\n\n<pre><code>enabled=false;\nmouseChildren=false;\n</code></pre>\n\n<p>on to the top most DisplayObje...
2009/02/12
[ "https://Stackoverflow.com/questions/543069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62255/" ]
Is there something like the java 'glasspane' in as3? *The glass pane is useful when you want to be able to catch events or paint over an area that already contains one or more components. For example, you can deactivate mouse events for a multi-component region by having the glass pane intercept the events. Or you can...
if you set ``` enabled=false; mouseChildren=false; ``` on to the top most DisplayObject it should disable all mouse events for your app. I've used it and it works a treat.
543,087
<p>I have a custom class file in C# that I inherited and partially extended. I am trying to <em>re factor</em> it now as I have just enough knowhow to know that with something like <em>generics</em>(I think) I could greatly condense this class. </p> <p>As an inexperienced solo dev I would greatly appreciate any dire...
[ { "answer_id": 543115, "author": "Steven DeWitt", "author_id": 62618, "author_profile": "https://Stackoverflow.com/users/62618", "pm_score": 1, "selected": false, "text": "<p>Have you tried ReSharper?\n<a href=\"http://www.jetbrains.com/resharper/\" rel=\"nofollow noreferrer\">http://www...
2009/02/12
[ "https://Stackoverflow.com/questions/543087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46724/" ]
I have a custom class file in C# that I inherited and partially extended. I am trying to *re factor* it now as I have just enough knowhow to know that with something like *generics*(I think) I could greatly condense this class. As an inexperienced solo dev I would greatly appreciate any direction or constructive crit...
You don't need generic to do this: ``` public static void ShowFormInControl(Control ctl, Form frm) { frm.TopLevel = false; frm.FormBorderStyle = FormBorderStyle.None; // Others rarely make sense frm.Dock = DockStyle.Fill; frm.Visible = true; ctl.Controls.Add(frm); } ``` Sample usage: ``` public Form1() {...
543,096
<h1>1 -</h1> <p>In my email-sending script, I store spaced-out emails in a string, then I use &quot;, &quot;.join(to.split()). However, it looks like the script only sends to the 1st email - is it something to do with RFC822 format? If so, how can I fix this?</p> <h1>2 -</h1> <p>I feel a bit edgy having my password vis...
[ { "answer_id": 545517, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 3, "selected": true, "text": "<p>Use <code>', '.join()</code> for the list in the <code>To:</code> or <code>Cc:</code> header, but the headers are only f...
2009/02/12
[ "https://Stackoverflow.com/questions/543096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6833/" ]
1 - === In my email-sending script, I store spaced-out emails in a string, then I use ", ".join(to.split()). However, it looks like the script only sends to the 1st email - is it something to do with RFC822 format? If so, how can I fix this? 2 - === I feel a bit edgy having my password visable in my script. Is there...
Use `', '.join()` for the list in the `To:` or `Cc:` header, but the headers are only for show. What determines where the mail actually goes is the RCPT envelope. Assuming you're using smtplib, that's the second argument: ``` connection.sendmail(senderaddress, to.split(), mailtext) ``` 2: it's possible, but far from...
543,101
<p>What is wrong with the statement below? I keep getting the following error message.... Server: Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'THEN'.</p> <pre><code>update oildatasetstatus set oildatasetstatusid = case WHEN 5 THEN 16 WHEN 6 THEN 17 WHEN 7 THE...
[ { "answer_id": 543117, "author": "John Sansom", "author_id": 60308, "author_profile": "https://Stackoverflow.com/users/60308", "pm_score": 2, "selected": false, "text": "<p>Looks like your case statement needs to specify which column is being tested for the given value.</p>\n\n<p>For exa...
2009/02/12
[ "https://Stackoverflow.com/questions/543101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59097/" ]
What is wrong with the statement below? I keep getting the following error message.... Server: Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'THEN'. ``` update oildatasetstatus set oildatasetstatusid = case WHEN 5 THEN 16 WHEN 6 THEN 17 WHEN 7 THEN 18 ...
The way you have your statement coded now will work (once you add the column reference to the case statement, as mentioned by other posts), however, to let the rest of your syntax go uncommented on would be a disservice to others in your situation. While you may only need to run this query once, I and others have run ...
543,104
<p>I'm trying to use Taylor series to develop a numerically sound algorithm for solving a function. I've been at it for quite a while, but haven't had any luck yet. I'm not sure what I'm doing wrong.</p> <p>The function is</p> <pre><code>f(x)=1 + x - sin(x)/ln(1+x) x~0 </code></pre> <p>Also: why does loss of preci...
[ { "answer_id": 543136, "author": "Steve", "author_id": 48552, "author_profile": "https://Stackoverflow.com/users/48552", "pm_score": 0, "selected": false, "text": "<p>I haven't looked into this that closely, but you should be aware that some taylor series converge very, very slowly.</p>\...
2009/02/12
[ "https://Stackoverflow.com/questions/543104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23323/" ]
I'm trying to use Taylor series to develop a numerically sound algorithm for solving a function. I've been at it for quite a while, but haven't had any luck yet. I'm not sure what I'm doing wrong. The function is ``` f(x)=1 + x - sin(x)/ln(1+x) x~0 ``` Also: why does loss of precision even occur in this function?...
Method used in question is correct - just make sure your calculator is in radians mode.
543,111
<p>I am new to iPhone development, so I'm sorry if this is a stupid question. I am developing an application whose purpose will be to route all iPhone activity through my company's proxy.</p> <p>Is there a way to programmatically set system-wide proxy settings in the iPhone (which will also take effect on the 3G conn...
[ { "answer_id": 543690, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": -1, "selected": false, "text": "<p>Pretty sure this is outside the Apple provided SDK sandbox. Probably possible with a jailbreak though.</p>\n" },...
2009/02/12
[ "https://Stackoverflow.com/questions/543111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20801/" ]
I am new to iPhone development, so I'm sorry if this is a stupid question. I am developing an application whose purpose will be to route all iPhone activity through my company's proxy. Is there a way to programmatically set system-wide proxy settings in the iPhone (which will also take effect on the 3G connection)? I...
If you're configuring iPhones in a commercial environment, you should look at the [Enterprise Deployment Guide](http://manuals.info.apple.com/en_US/Enterprise_Deployment_Guide.pdf). Specifically, you should look at using the iPhone Configuration Utility to create a \*.mobileconfig configuration file that can be distrib...
543,130
<p>I have some old Java 2D code I want to reuse, but was wondering, is this the best way to get the highest quality images?</p> <pre><code> public static BufferedImage getScaled(BufferedImage imgSrc, Dimension dim) { // This code ensures that all the pixels in the image are loaded. Image scaled = imgSrc.g...
[ { "answer_id": 543157, "author": "JeffFoster", "author_id": 9853, "author_profile": "https://Stackoverflow.com/users/9853", "pm_score": 2, "selected": false, "text": "<p>You can use JAI (Java Advanced Imaging) to get more sophisticated image resizing options. See <a href=\"https://jai.d...
2009/02/12
[ "https://Stackoverflow.com/questions/543130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22801/" ]
I have some old Java 2D code I want to reuse, but was wondering, is this the best way to get the highest quality images? ``` public static BufferedImage getScaled(BufferedImage imgSrc, Dimension dim) { // This code ensures that all the pixels in the image are loaded. Image scaled = imgSrc.getScaledInstan...
Chris Campbell has an excellent and detailed write-up on scaling images - see **[this article](http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html)**. Chet Haase and Romain Guy also have a detailed and very informative write-up of image scaling in their book, **[Filthy Rich Clients](htt...
543,141
<p>For Example, is there any way to do something like the following:</p> <pre><code>INSERT INTO table2 VALUES(SELECT x FROM table1 WHERE x &gt; 5 LIMIT 4) </code></pre>
[ { "answer_id": 543150, "author": "Graeme Perrow", "author_id": 1821, "author_profile": "https://Stackoverflow.com/users/1821", "pm_score": 4, "selected": true, "text": "<p>Remove VALUES and the brackets:</p>\n\n<pre><code>INSERT INTO table2 SELECT x FROM table1 WHERE x &gt; 5 LIMIT 4\n</...
2009/02/12
[ "https://Stackoverflow.com/questions/543141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85/" ]
For Example, is there any way to do something like the following: ``` INSERT INTO table2 VALUES(SELECT x FROM table1 WHERE x > 5 LIMIT 4) ```
Remove VALUES and the brackets: ``` INSERT INTO table2 SELECT x FROM table1 WHERE x > 5 LIMIT 4 ```
543,155
<p>How do you print directly to a dot matrix printer in C# using file LPT1. </p> <p>I did it on C++ with fopen, but I don't know how to do it in c#.</p> <p>thank you very much</p>
[ { "answer_id": 543206, "author": "geofftnz", "author_id": 20122, "author_profile": "https://Stackoverflow.com/users/20122", "pm_score": 4, "selected": false, "text": "<p>Set up the printer in Windows as Generic/Text Only, then print to it.</p>\n\n<p>Here's the code I use to print to a la...
2009/02/12
[ "https://Stackoverflow.com/questions/543155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you print directly to a dot matrix printer in C# using file LPT1. I did it on C++ with fopen, but I don't know how to do it in c#. thank you very much
Set up the printer in Windows as Generic/Text Only, then print to it. Here's the code I use to print to a label printer that has its own encoded text format. ``` using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Drawing.Printing; using System.Windows.Forms; using Sy...
543,161
<p>I'm new to Cocoa/Cocoa Touch, and working through a development book. I've come across situations where the @selector() operator is used. I'm a bit lost on how and when the @selector() operator should be used. Can someone provide a short and sweet explanation and example of why it's used and what benefit it gives...
[ { "answer_id": 543197, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 6, "selected": true, "text": "<p>The selector operator provides a way to refer to a method provided by an object, somewhat similar to a function point...
2009/02/12
[ "https://Stackoverflow.com/questions/543161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5675/" ]
I'm new to Cocoa/Cocoa Touch, and working through a development book. I've come across situations where the @selector() operator is used. I'm a bit lost on how and when the @selector() operator should be used. Can someone provide a short and sweet explanation and example of why it's used and what benefit it gives the d...
The selector operator provides a way to refer to a method provided by an object, somewhat similar to a function pointer in C. It is useful because it allows you to decouple the process of calling methods on an object. For example one piece of code could provide a method, and another piece of code could apply that metho...
543,196
<p>I'm tired of inserting</p> <pre><code>import pdb; pdb.set_trace() </code></pre> <p>lines into my Python programs and debugging through the console. How do I connect a remote debugger and insert breakpoints from a civilized user interface?</p>
[ { "answer_id": 543258, "author": "Johan Dahlin", "author_id": 14337, "author_profile": "https://Stackoverflow.com/users/14337", "pm_score": 4, "selected": false, "text": "<p>Well, you can get something quite similar to that using a twisted manhole, which\nworks like this:</p>\n\n<pre><co...
2009/02/12
[ "https://Stackoverflow.com/questions/543196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36330/" ]
I'm tired of inserting ``` import pdb; pdb.set_trace() ``` lines into my Python programs and debugging through the console. How do I connect a remote debugger and insert breakpoints from a civilized user interface?
use [Winpdb](http://winpdb.org/). It is a **platform independent** graphical GPL Python debugger with support for remote debugging over a network, multiple threads, namespace modification, embedded debugging, encrypted communication and is up to 20 times faster than pdb. Features: * GPL license. Winpdb is Free Softwa...
543,199
<p>I need script to add quotes in url string from url.txt</p> <p>from <code>http://www.site.com/info.xx</code> to <code>"http://www.site.com/info.xx"</code></p>
[ { "answer_id": 543210, "author": "Evan Fosmark", "author_id": 49701, "author_profile": "https://Stackoverflow.com/users/49701", "pm_score": 3, "selected": false, "text": "<pre><code>url = '\"%s\"' % url\n</code></pre>\n\n<p>Example:</p>\n\n<pre><code>line = 'http://www.site.com/info.xx ...
2009/02/12
[ "https://Stackoverflow.com/questions/543199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65122/" ]
I need script to add quotes in url string from url.txt from `http://www.site.com/info.xx` to `"http://www.site.com/info.xx"`
``` url = '"%s"' % url ``` Example: ``` line = 'http://www.site.com/info.xx \n' url = '"%s"' % line.strip() print url # "http://www.site.com/info.xx" ``` Remember, adding a backslash before a quotation mark will escape it and therefore won't end the string.
543,203
<p>I'm using <a href="/questions/tagged/cmake" class="post-tag" title="show questions tagged &#39;cmake&#39;" rel="tag">cmake</a> for managing my cross-platform builds, and I have everything worked out except for this problem. I set <code>RUNTIME_OUTPUT_DIRECTORY</code> to a <code>bin/</code> directory where I have dat...
[ { "answer_id": 558180, "author": "Jon Tackabury", "author_id": 343, "author_profile": "https://Stackoverflow.com/users/343", "pm_score": 2, "selected": false, "text": "<p>I found a few good discussions on this topic:</p>\n\n<p><a href=\"http://www.cmake.org/pipermail/cmake/2008-April/021...
2009/02/12
[ "https://Stackoverflow.com/questions/543203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1631/" ]
I'm using [cmake](/questions/tagged/cmake "show questions tagged 'cmake'") for managing my cross-platform builds, and I have everything worked out except for this problem. I set `RUNTIME_OUTPUT_DIRECTORY` to a `bin/` directory where I have data files stored. On Linux, this works fine. On Windows, the executables get pl...
I've been using the fine prefix property hack reported by [Ogapo](https://stackoverflow.com/users/123518/ogapo) for years. It works. But as of CMake version 2.8, there is official support for avoiding the Release/Debug subdirectories on Windows. Use either the global `CMAKE_<ARTIFACT>_OUTPUT_DIRECTORY_<CONFIGURATION...
543,208
<p>Given a bunch of paragraphs:</p> <pre><code>Para. A ... Para. B ... Para. C ... </code></pre> <p>How can one have LaTeX automatically number them, i.e.</p> <pre><code>1. Para. A. ... 2. Para. B. ... 3. Para. C. ... </code></pre> <p>I've seen the following suggested:</p> <pre><code>\newcounter{parnum} \newco...
[ { "answer_id": 543332, "author": "Jon Ericson", "author_id": 1438, "author_profile": "https://Stackoverflow.com/users/1438", "pm_score": 2, "selected": false, "text": "<p>I believe another option is the <code>ledmac</code> package. Here is a quote from the documentation:</p>\n\n<blockqu...
2009/02/12
[ "https://Stackoverflow.com/questions/543208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19212/" ]
Given a bunch of paragraphs: ``` Para. A ... Para. B ... Para. C ... ``` How can one have LaTeX automatically number them, i.e. ``` 1. Para. A. ... 2. Para. B. ... 3. Para. C. ... ``` I've seen the following suggested: ``` \newcounter{parnum} \newcommand{\N}{% \noindent\refstepcounter{parnum}% \makebo...
I think there are three possible solutions (at least!) which don't involve rolling your own or someone else's macro, depending on exactly what you are trying to do. 1 If the numbering is required throughout the document, use `\paragraph`, which is a lower-level sectioning command (like \chapter, \section, \subsection,...
543,215
<p>Ok, so I'm getting a <em>little</em> annoyed with Maven 2 right now. The project setup we've got is simple: A "core" project, which is depended on by both a "batch" and "web" project, and an "ear" project which depends on "web". Pretty simple stuff.</p> <p>Well, since core is used quite a bit, and this is the fir...
[ { "answer_id": 543889, "author": "whaley", "author_id": 46375, "author_profile": "https://Stackoverflow.com/users/46375", "pm_score": 0, "selected": false, "text": "<p>This is not a problem with your maven distribution itself.</p>\n\n<p>In general, use <code>mvn dependency:tree</code> wh...
2009/02/12
[ "https://Stackoverflow.com/questions/543215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8026/" ]
Ok, so I'm getting a *little* annoyed with Maven 2 right now. The project setup we've got is simple: A "core" project, which is depended on by both a "batch" and "web" project, and an "ear" project which depends on "web". Pretty simple stuff. Well, since core is used quite a bit, and this is the first time the group i...
You should check mvn help:effective-pom with and without the offending chunk. You may also be getting bitten by [this bug](http://jira.codehaus.org/browse/MNG-2045), but you'll have to see if it applies to your parentage situation. In any case, you really should at least try it in a temporary area with maven 2.0.9 .....
543,225
<p>I'm consuming a data feed that has recently added a Unicode BOM header (U+FEFF), and my rake task is now messed up by it.</p> <p>I can skip the first 3 bytes with <code>file.gets[3..-1]</code> but is there a more elegant way to read files in Ruby which can handle this correctly, whether a BOM is present or not?</p>...
[ { "answer_id": 546277, "author": "Alan Moore", "author_id": 20938, "author_profile": "https://Stackoverflow.com/users/20938", "pm_score": 4, "selected": false, "text": "<p>I wouldn't blindly skip the first three bytes; what if the producer <em>stops</em> adding the BOM again? What you s...
2009/02/12
[ "https://Stackoverflow.com/questions/543225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61439/" ]
I'm consuming a data feed that has recently added a Unicode BOM header (U+FEFF), and my rake task is now messed up by it. I can skip the first 3 bytes with `file.gets[3..-1]` but is there a more elegant way to read files in Ruby which can handle this correctly, whether a BOM is present or not?
With ruby 1.9.2 you can use the mode `r:bom|utf-8` ``` text_without_bom = nil #define the variable outside the block to keep the data File.open('file.txt', "r:bom|utf-8"){|file| text_without_bom = file.read } ``` or ``` text_without_bom = File.read('file.txt', encoding: 'bom|utf-8') ``` or ``` text_without_bo...
543,243
<p>I'm really struggling with something here. I have a class module, let's call it FormMan which has a bunch of methods relating to the large number of userforms I have in my project. One particular method is to be called from a lot of different places and is pretty simple - it simply adds a user defined number of cont...
[ { "answer_id": 543302, "author": "Adam Ralph", "author_id": 49241, "author_profile": "https://Stackoverflow.com/users/49241", "pm_score": 3, "selected": true, "text": "<p>The problem here is that the UserForm and frmTest objects are not of the same type. In fact, frmTest is a subtype of ...
2009/02/12
[ "https://Stackoverflow.com/questions/543243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51498/" ]
I'm really struggling with something here. I have a class module, let's call it FormMan which has a bunch of methods relating to the large number of userforms I have in my project. One particular method is to be called from a lot of different places and is pretty simple - it simply adds a user defined number of control...
The problem here is that the UserForm and frmTest objects are not of the same type. In fact, frmTest is a subtype of UserForm that extends it by adding the Height property, amongst other members. You'll probably have to resort to declaring your function parameter as Object. ``` Public Sub Addcontrols(iNum as integer,...
543,254
<p>Say for example you have a base abstract class</p> <pre><code>public abstract Foo { IFlyable _fly; ISwimmable _swim; void performSwim() { _swim.swim(); } void performFly() { _fly.fly(); } } </code></pre> <p>And have behaviors/algorithm that you will have in your system</p> <pre><code>interfa...
[ { "answer_id": 543429, "author": "notnot", "author_id": 65184, "author_profile": "https://Stackoverflow.com/users/65184", "pm_score": -1, "selected": false, "text": "<p>So here's my take on this:</p>\n\n<pre><code>public enum ActionType\n{\n Swim, Vote, Fly\n};\n\npublic interface IBeh...
2009/02/12
[ "https://Stackoverflow.com/questions/543254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Say for example you have a base abstract class ``` public abstract Foo { IFlyable _fly; ISwimmable _swim; void performSwim() { _swim.swim(); } void performFly() { _fly.fly(); } } ``` And have behaviors/algorithm that you will have in your system ``` interface IFlyable { void fly(); } interface...
Try the decorator pattern. To support a new behavior, you would just implement a new class that inherits from `Foo`, implements `IWeaponBehavior`, and decorates another `Foo` object. Then you can now use the `WeaponDecorator` as a `Foo` or `IWeaponBehavior` and still have access to the base `Foo` that it decorates. Ba...
543,256
<p>Is there a way to tell .Net to search for a namespace from the <em>root</em> of the namespace tree?</p> <p>Say I have these two, completely independent, namespaces:</p> <pre><code>Apple.Orange.Banana Orange.Grape.Peach </code></pre> <p>Assume they came from different programmers and the "Orange" in each one is co...
[ { "answer_id": 543289, "author": "Mark", "author_id": 18264, "author_profile": "https://Stackoverflow.com/users/18264", "pm_score": 2, "selected": false, "text": "<p>You could alias the root Orange like this:</p>\n\n<pre><code>using RootOrange = Orange;\n</code></pre>\n\n<p>Then you can ...
2009/02/12
[ "https://Stackoverflow.com/questions/543256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60733/" ]
Is there a way to tell .Net to search for a namespace from the *root* of the namespace tree? Say I have these two, completely independent, namespaces: ``` Apple.Orange.Banana Orange.Grape.Peach ``` Assume they came from different programmers and the "Orange" in each one is completely coincidental. If I'm inside "A...
Have you tried using the global:: resolution scope? For example, if you have the following: ``` private global::Orange.Grape.Peach.classname x; ``` Also, you get different resolution depending on whether namespaces are imported outside of a namespace declaration or inside, so ``` using System.Linq; namespace MyLinq...
543,263
<p>In C#, what's the difference between </p> <pre><code>Assert.AreNotEqual </code></pre> <p>and </p> <pre><code>Assert.AreNotSame </code></pre>
[ { "answer_id": 543276, "author": "Godeke", "author_id": 28006, "author_profile": "https://Stackoverflow.com/users/28006", "pm_score": 5, "selected": false, "text": "<p>Two things can be equal, but different objects. AreNotEqual checks the objects <em>values</em> via the equality test, wh...
2009/02/12
[ "https://Stackoverflow.com/questions/543263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19020/" ]
In C#, what's the difference between ``` Assert.AreNotEqual ``` and ``` Assert.AreNotSame ```
Almost all the answers given here are correct, but it's probably worth giving an example: ``` public static string GetSecondWord(string text) { // Yes, an appalling implementation... return text.Split(' ')[1]; } string expected = "world"; string actual = GetSecondWord("hello world"); // Good: the two strings...
543,264
<p>I used this code to maintain scroll position and don't have a clue of what it means. If someone has the time, can you provide me with an step by step explanation of what it is doing. Here it is:</p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; var xPos, yPos; var prm = Sys.WebFo...
[ { "answer_id": 543280, "author": "Allen Rice", "author_id": 49885, "author_profile": "https://Stackoverflow.com/users/49885", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms534617(VS.85).aspx\" rel=\"nofollow noreferrer\">scrollLeft</a> ...
2009/02/12
[ "https://Stackoverflow.com/questions/543264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
I used this code to maintain scroll position and don't have a clue of what it means. If someone has the time, can you provide me with an step by step explanation of what it is doing. Here it is: ``` <script language="javascript" type="text/javascript"> var xPos, yPos; var prm = Sys.WebForms.PageRequestManager...
``` var xPos, yPos; // global variable declaration var prm = Sys.WebForms.PageRequestManager.getInstance(); // Some webforms javascript manager /* * Begin function with 2 arguments */ function BeginRequestHandler(sender, args) { // check if the element generated by .net with id 'lstAuctions.ClientID' exists i...
543,269
<p>I have an ASP.NET MVC (using the release candidate) application that works with a class library that among other things uses LINQ to SQL for data persistance.</p> <p>One of the thing the app/db maintains, is the concept of a "Folder" - like a disk folder, but with a hierarchy that only exists in the database. Other...
[ { "answer_id": 543304, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Is there a way to tell LINQ to SQL \"Hey, I know what you're thinking, but DROP IT ALL, and just get ALL the...
2009/02/12
[ "https://Stackoverflow.com/questions/543269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2122/" ]
I have an ASP.NET MVC (using the release candidate) application that works with a class library that among other things uses LINQ to SQL for data persistance. One of the thing the app/db maintains, is the concept of a "Folder" - like a disk folder, but with a hierarchy that only exists in the database. Other database ...
> > Is there a way to tell LINQ to SQL "Hey, I know what you're thinking, but DROP IT ALL, and just get ALL the data from the database, NOW!"? > > > db = new customDataContext(); > > db is of course the local, static DataContext reference > > > Yeah, watch out there. ASP.NET is multithreaded and you don't wa...
543,277
<p>I am looking for tooltip plugins for jQuery that would allow for the following type of behavior.</p> <pre><code>&lt;a href="somewhere.html"&gt; &lt;span&gt; &lt;img src="someimage.jpg" style="display: none;" /&gt; Here is the tooltip content. &lt;/span&gt; Here is the link to somewhere. &lt;/a&gt; </code></p...
[ { "answer_id": 543303, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 3, "selected": false, "text": "<p>I am a big fan of <a href=\"http://www.lullabot.com/files/bt/bt-latest/DEMO/index.html\" rel=\"noreferrer\"><c...
2009/02/12
[ "https://Stackoverflow.com/questions/543277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62983/" ]
I am looking for tooltip plugins for jQuery that would allow for the following type of behavior. ``` <a href="somewhere.html"> <span> <img src="someimage.jpg" style="display: none;" /> Here is the tooltip content. </span> Here is the link to somewhere. </a> ``` The behavior that I am hoping for is to hover ov...
OHHHHHHHH Best one ever! <http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/> Demos: (look for the the "Link to yahoo" example to meet all of your needs) <http://jquery.bassistance.de/tooltip/demo/> EDIT: i see you mentioned Jorn (i didn't know his name) but look for the "yahoo" example it should do what y...
543,282
<p>I just made a text animation (fade in; animate(top, opacity)) and at the end, the text went about 5px left then returned to its original position, quite quickly. This happened in IE only; all other major browsers behaved normally.</p> <p>Any idea about why it happens, and how to fix it? I am interested in fixing I...
[ { "answer_id": 543355, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": "<p>Try wrapping in a div with fixed dimensions.</p>\n" }, { "answer_id": 543374, "author": ...
2009/02/12
[ "https://Stackoverflow.com/questions/543282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I just made a text animation (fade in; animate(top, opacity)) and at the end, the text went about 5px left then returned to its original position, quite quickly. This happened in IE only; all other major browsers behaved normally. Any idea about why it happens, and how to fix it? I am interested in fixing IE7 in parti...
It would help if you could post a minimized working sample so we can look at the code. My best guess is that you need to wrap your element with a block-level element (`div` or `p`) and give that element '`position: relative;`' for IE to behave.
543,283
<p>Look at this great screenshot and I think you can imagine what I could ask... </p> <p><a href="http://a4.s3.p.quickshareit.com/files/screenshot_75d0fc54a05ec7eae3f410.png" rel="nofollow noreferrer">screenshot http://a4.s3.p.quickshareit.com/files/screenshot_75d0fc54a05ec7eae3f410.png</a> The players:</p> <blockqu...
[ { "answer_id": 543888, "author": "Dirk Stoop", "author_id": 24051, "author_profile": "https://Stackoverflow.com/users/24051", "pm_score": 1, "selected": false, "text": "<p>If I understand your description of how everything is built up correctly, selectedObject in your NSPopupButton is bo...
2009/02/12
[ "https://Stackoverflow.com/questions/543283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59518/" ]
Look at this great screenshot and I think you can imagine what I could ask... [screenshot http://a4.s3.p.quickshareit.com/files/screenshot\_75d0fc54a05ec7eae3f410.png](http://a4.s3.p.quickshareit.com/files/screenshot_75d0fc54a05ec7eae3f410.png) The players: > > to the right: the preferences-panel and a `NSTableView...
I have it! I just unbinded the selected object of the NSPopUpButton and binded it again. It performs this action `only` when the selected object was removed from list. ;)
543,307
<p>I'm expecting this output:</p> <pre><code>output:xyz </code></pre> <p>But if I type the following:</p> <pre><code>a = ["x", "y", "z"] print "output:" + a.each {|i| print i}.to_s </code></pre> <p>Why do I get an 'xyz' before the word output as well as after it?</p> <pre><code>xyzoutput:xyz </code></pre>
[ { "answer_id": 543378, "author": "womble", "author_id": 60003, "author_profile": "https://Stackoverflow.com/users/60003", "pm_score": 3, "selected": true, "text": "<p>In irb:</p>\n\n<pre><code>&gt;&gt; %w{x y z}.each {|i| i }\n=&gt; [\"x\", \"y\", \"z\"]\n</code></pre>\n\n<p>The return v...
2009/02/12
[ "https://Stackoverflow.com/questions/543307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm expecting this output: ``` output:xyz ``` But if I type the following: ``` a = ["x", "y", "z"] print "output:" + a.each {|i| print i}.to_s ``` Why do I get an 'xyz' before the word output as well as after it? ``` xyzoutput:xyz ```
In irb: ``` >> %w{x y z}.each {|i| i } => ["x", "y", "z"] ``` The return value of a call to `each` is the `Enumerable` object that it was called on. So you're basically printing out each element of the array in the block you're passing to `each`, and then converting the array to a string and printing it again, havin...
543,309
<p>Is it possible to stop execution of a python script at any line with a command?</p> <p>Like</p> <pre><code>some code quit() # quit at this point some more code (that's not executed) </code></pre>
[ { "answer_id": 543322, "author": "Moses Schwartz", "author_id": 60900, "author_profile": "https://Stackoverflow.com/users/60900", "pm_score": 10, "selected": true, "text": "<p><a href=\"https://docs.python.org/2/library/sys.html#sys.exit\" rel=\"noreferrer\">sys.exit()</a> will do exactl...
2009/02/12
[ "https://Stackoverflow.com/questions/543309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51816/" ]
Is it possible to stop execution of a python script at any line with a command? Like ``` some code quit() # quit at this point some more code (that's not executed) ```
[sys.exit()](https://docs.python.org/2/library/sys.html#sys.exit) will do exactly what you want. ``` import sys sys.exit("Error message") ```
543,311
<p>I have the following sample query,</p> <pre><code>select o.ENTRY_ID, o.DESCRIPTION, o.ENTRY_DATE, l.COMPANY_ID from TABLE1 o, TABLE2 l where o.ENTRY_ID = l.ENTRY_ID and COMPANY_ID in (10, 11, 12, 13) </code></pre> <p>that would return a set of data similar to the following:</p> <pre><code>ENTRY_ID, DESCRIPTION...
[ { "answer_id": 543376, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 2, "selected": false, "text": "<pre><code>SELECT ENTRY_ID, DESCRIPTION, ENTRY_DATE, COMPANY_ID\nFROM (\n SELECT o.ENTRY_ID, o.DESCRIPTION, o.ENTRY_DATE...
2009/02/12
[ "https://Stackoverflow.com/questions/543311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have the following sample query, ``` select o.ENTRY_ID, o.DESCRIPTION, o.ENTRY_DATE, l.COMPANY_ID from TABLE1 o, TABLE2 l where o.ENTRY_ID = l.ENTRY_ID and COMPANY_ID in (10, 11, 12, 13) ``` that would return a set of data similar to the following: ``` ENTRY_ID, DESCRIPTION, ENTRY_DATE, COMPANY_ID 1, Descripti...
``` SELECT ENTRY_ID, DESCRIPTION, ENTRY_DATE, COMPANY_ID FROM ( SELECT o.ENTRY_ID, o.DESCRIPTION, o.ENTRY_DATE, l.COMPANY_ID, ROW_NUMBER() OVER (PARTITION BY company_id ORDER BY entry_date DESC, entry_id DESC) AS rn FROM TABLE1 o, TABLE2 l WHERE o.ENTRY_ID = l.ENTRY_ID AND COMPANY_ID in (10, 11, 12...
543,319
<p>I have encountered many half-solutions to the task of returning XML in ASP.NET. I don't want to blindly copy &amp; paste some code that happens to work most of the time, though; I want the <em>right</em> code, and I want to know <em>why</em> it's right. I want criticism; I want information; I want knowledge; I want ...
[ { "answer_id": 543380, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": -1, "selected": false, "text": "<p>You've basically answered anything and everything already, so I'm no sure what the point is here?</p>\n\n<p>FWIW <em>...
2009/02/12
[ "https://Stackoverflow.com/questions/543319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
I have encountered many half-solutions to the task of returning XML in ASP.NET. I don't want to blindly copy & paste some code that happens to work most of the time, though; I want the *right* code, and I want to know *why* it's right. I want criticism; I want information; I want knowledge; I want understanding. Below...
I've found the proper way to return XML to a client in ASP.NET. I think if I point out the wrong ways, it will make the right way more understandable. **Incorrect:** ``` Response.Write(doc.ToString()); ``` **Incorrect:** ``` Response.Write(doc.InnerXml); ``` **Incorrect:** ``` Response.ContentType = "text/xml";...
543,336
<p>How do I redirect stdin from a shell script to a command in the shell script? I am trying to pass the stdin to a java System.in stream.</p> <p>I want to replace</p> <pre><code>find . -type f | $JAVA_HOME/bin/java com.domain.BatchProcess </code></pre> <p>with</p> <pre><code> find . -type f | ./batch.sh </code></...
[ { "answer_id": 543361, "author": "Dave Stenglein", "author_id": 57679, "author_profile": "https://Stackoverflow.com/users/57679", "pm_score": 3, "selected": false, "text": "<p>If you exec the command within the script, it will replace the shell and inherit it's file descriptors,\nincludi...
2009/02/12
[ "https://Stackoverflow.com/questions/543336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22801/" ]
How do I redirect stdin from a shell script to a command in the shell script? I am trying to pass the stdin to a java System.in stream. I want to replace ``` find . -type f | $JAVA_HOME/bin/java com.domain.BatchProcess ``` with ``` find . -type f | ./batch.sh ```
If the command: ``` $JAVA_HOME/bin/java com.domain.BatchProcess ``` is expecting input from stdin, then putting it in a script and running your second command will work.
543,346
<p>Do you have a clean way to list all the files that ever existed in specified branch?</p>
[ { "answer_id": 543383, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 2, "selected": false, "text": "<p>You can run <code>git-log --name-status</code>, which echoes something like:</p>\n\n<pre><code>commit afdbbaf52ab24ef7c...
2009/02/12
[ "https://Stackoverflow.com/questions/543346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277510/" ]
Do you have a clean way to list all the files that ever existed in specified branch?
This is a simplified variation of Strager's [solution](https://stackoverflow.com/a/543383/313192): ``` git log --pretty=format: --name-status | cut -f2- | sort -u ``` **Edit:** Thanks to Jakub for teaching me a bit more in the comments, this version has a shorter pipeline and gives git more opportunity to get things...
543,377
<p>I want to have two foreign keys to the same model:</p> <pre><code>class Test(models.model): example1 = models.ForeignKey(Example) example2 = models.ForeignKey(Example) </code></pre> <p>I get errors like:</p> <blockquote> <p>Accessor for field 'example1' clashes with related field 'Example.test_set'. A...
[ { "answer_id": 543406, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 7, "selected": false, "text": "<p>Try using <a href=\"http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey\" rel=\"noreferrer\"><code>relat...
2009/02/12
[ "https://Stackoverflow.com/questions/543377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36680/" ]
I want to have two foreign keys to the same model: ``` class Test(models.model): example1 = models.ForeignKey(Example) example2 = models.ForeignKey(Example) ``` I get errors like: > > Accessor for field 'example1' clashes with related > field 'Example.test\_set'. Add a related\_name argument > to the def...
Django uses some python magic to define relationships between models, some of which involves using the name of the models in the relationships (that's where the 'test' in 'test\_\_set' is coming from.) What's happening, I would guess, is that it's trying to put "test\_\_set" in the Example model twice, once for each fo...
543,379
<p>When editing non-WYSIWYG (LaTeX, HTML, etc) prose you probably want to have newlines at the ends of your sentences. This has several advantages:</p> <ol> <li>Easier to rearrange sentences.</li> <li>Easier to comment out sentences.</li> <li>Easier to spot run-on / overly long sentences.</li> <li>Easier to comment <e...
[ { "answer_id": 544061, "author": "yungchin", "author_id": 25756, "author_profile": "https://Stackoverflow.com/users/25756", "pm_score": 2, "selected": false, "text": "<p>I'd think the simplest solution to this is to only add newlines after full stops. Your edits would then never fragment...
2009/02/12
[ "https://Stackoverflow.com/questions/543379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
When editing non-WYSIWYG (LaTeX, HTML, etc) prose you probably want to have newlines at the ends of your sentences. This has several advantages: 1. Easier to rearrange sentences. 2. Easier to comment out sentences. 3. Easier to spot run-on / overly long sentences. 4. Easier to comment *on* sentences. For example: ``...
I'd think the simplest solution to this is to only add newlines after full stops. Your edits would then never fragment lines. Note that for prose you can very well rely on your editor's line-wrapping features to wrap long sentences - unless you insist on indenting it like you would with code (I don't indent that much...
543,387
<p>I am using a macro to export a table in a Microsoft Access database to a csv file in order to import into a mysql database. I ended up using a batchfile that would place a marker in the text file before the exporting took place, and then place everything after the last marker into a new file. This works fine, except...
[ { "answer_id": 543447, "author": "BIBD", "author_id": 685, "author_profile": "https://Stackoverflow.com/users/685", "pm_score": 1, "selected": false, "text": "<p>a) force access to append to a file, or to place a marker of its own</p>\n\n<p>No. The exports is expecting to write a complet...
2009/02/12
[ "https://Stackoverflow.com/questions/543387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I am using a macro to export a table in a Microsoft Access database to a csv file in order to import into a mysql database. I ended up using a batchfile that would place a marker in the text file before the exporting took place, and then place everything after the last marker into a new file. This works fine, except fo...
Instead of using a macro to export the table you could simply create some code to open the file, and append the data to it. **How to use** Simply copy the code to a VBA module in your application and call it like this: ``` ' Export the Table "Orders" to "orders.csv", appending the data to the ' ' existing file...
543,399
<p>I see you guys using</p> <pre><code>url = '"%s"' % url # This part &gt;&gt;&gt; url = "http://www.site.com/info.xx" &gt;&gt;&gt; print url http://www.site.com/info.xx &gt;&gt;&gt; url = '"%s"' % url &gt;&gt;&gt; print url "http://www.site.com/info.xx" </code></pre> <p>Is it advanced Python? Is there a tutorial fo...
[ { "answer_id": 543416, "author": "Andrea Ambu", "author_id": 21384, "author_profile": "https://Stackoverflow.com/users/21384", "pm_score": 0, "selected": false, "text": "<p>It is not advanced, you can use ' or \" to define a string.</p>\n\n<p>Check the <a href=\"http://docs.python.org/re...
2009/02/12
[ "https://Stackoverflow.com/questions/543399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65122/" ]
I see you guys using ``` url = '"%s"' % url # This part >>> url = "http://www.site.com/info.xx" >>> print url http://www.site.com/info.xx >>> url = '"%s"' % url >>> print url "http://www.site.com/info.xx" ``` Is it advanced Python? Is there a tutorial for it? How can I learn about it?
It's common string formatting, and very useful. It's analogous to C-style printf formatting. See [String Formatting Operations](http://docs.python.org/library/stdtypes.html#string-formatting) in the Python.org docs. You can use multiple arguments like this: ``` "%3d\t%s" % (42, "the answer to ...") ```
543,414
<p>Background: I'm creating a WPF app using MVVM, and using a DI container to build my ViewModels</p> <p>My App.xaml looks like this:</p> <pre><code>&lt;Application x:Class="WpfApp.App" ...xmlns etc... StartupUri="MainWindow.xaml"&gt; &lt;Application.Resources&gt; &lt;app:ServiceLocator x:Key="ser...
[ { "answer_id": 555286, "author": "Nidonocu", "author_id": 483, "author_profile": "https://Stackoverflow.com/users/483", "pm_score": 7, "selected": true, "text": "<p>Rather than overriding OnStartup, try using an event instead:</p>\n\n<pre><code>&lt;Application x:Class=\"My.App\"\n xml...
2009/02/12
[ "https://Stackoverflow.com/questions/543414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
Background: I'm creating a WPF app using MVVM, and using a DI container to build my ViewModels My App.xaml looks like this: ``` <Application x:Class="WpfApp.App" ...xmlns etc... StartupUri="MainWindow.xaml"> <Application.Resources> <app:ServiceLocator x:Key="serviceLocator" /> </Application.Re...
Rather than overriding OnStartup, try using an event instead: ``` <Application x:Class="My.App" xmlns="..." Startup="Application_Startup" ShutdownMode="OnExplicitShutdown"> <Application.Resources> <app:ServiceLocator x:Key="serviceLocator" /> </Application.Resources> </Appli...
543,442
<p>I need to shorten this query and while I'm pretty good at SQL, I'm still learning.</p> <pre><code> SELECT 'doejoh', DATETIME, [Recipient-Address], [Message-Subject], [Sender-Address] FROM dbo.Logs WHERE LEFT([Recipient-Address], 6) IN ('doejoh') UNION ALL S...
[ { "answer_id": 543459, "author": "marc_s", "author_id": 13302, "author_profile": "https://Stackoverflow.com/users/13302", "pm_score": 3, "selected": false, "text": "<p>You should rewrite your query as:</p>\n\n<pre><code>SELECT\n 'doejoh',\n DATETIME,\n [Recipient-Address], [Message...
2009/02/12
[ "https://Stackoverflow.com/questions/543442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38317/" ]
I need to shorten this query and while I'm pretty good at SQL, I'm still learning. ``` SELECT 'doejoh', DATETIME, [Recipient-Address], [Message-Subject], [Sender-Address] FROM dbo.Logs WHERE LEFT([Recipient-Address], 6) IN ('doejoh') UNION ALL SELECT ...
Is there a reason something like this won't work? ``` CREATE TABLE #TempNames ( shortname nvarchar(6), longname nvarchar(10) ) INSERT INTO #TempNames (shortname, longname) VALUES('doejoh', 'john.doe@g') INSERT INTO #TempNames (shortname, longname) VALUES('doejan', 'jan.doe@g') INSERT INTO #TempNames (shortnam...
543,451
<p>I have a database table that looks like:</p> <pre><code> ForeignId: int Key: varchar Value: varchar </code></pre> <p>Where ForeignId and Key constitute a unique primary key</p> <p>I can easily determine the total set of keys defined for a given set of document with</p> <pre><code> SELECT DISTINCT [Key] FROM [Tab...
[ { "answer_id": 543878, "author": "Chris", "author_id": 64968, "author_profile": "https://Stackoverflow.com/users/64968", "pm_score": 1, "selected": false, "text": "<p>Ok - so if I understand your question you need to generate a list containing two columns, key and value.</p>\n\n<p>The li...
2009/02/12
[ "https://Stackoverflow.com/questions/543451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a database table that looks like: ``` ForeignId: int Key: varchar Value: varchar ``` Where ForeignId and Key constitute a unique primary key I can easily determine the total set of keys defined for a given set of document with ``` SELECT DISTINCT [Key] FROM [Table] WHERE [ForeignId] IN (...) ``` What I ...
Ok - so if I understand your question you need to generate a list containing two columns, key and value. The list will have a single row for each and every key, the value column can be defined as: NULL if it is not defined for all ForeignID' NULL if it is defined for all keys but contains multiple values The value if...
543,454
<p>Suppose I have an array of a objects of user defined class. Wanted to know how do I extract the elements of the array in PHP.</p> <pre><code>// class definition class User { public $fname; public $lname; } // array of objects of the class defined above $objUser1 = new User(): $objUser2 = new User(): $objUser3 = ne...
[ { "answer_id": 543470, "author": "TJ L", "author_id": 12605, "author_profile": "https://Stackoverflow.com/users/12605", "pm_score": 4, "selected": true, "text": "<pre><code>foreach ($alUser as $user) {\n $obj = $user;\n}\n</code></pre>\n\n<p>Why do you need typecasting for this?</p>\n...
2009/02/12
[ "https://Stackoverflow.com/questions/543454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/241755/" ]
Suppose I have an array of a objects of user defined class. Wanted to know how do I extract the elements of the array in PHP. ``` // class definition class User { public $fname; public $lname; } // array of objects of the class defined above $objUser1 = new User(): $objUser2 = new User(): $objUser3 = new User(): $obj...
``` foreach ($alUser as $user) { $obj = $user; } ``` Why do you need typecasting for this?
543,482
<p>So I have a collection of objects. The exact type isn't important. From it I want to extract all the unique pairs of a pair of particular properties, thusly:</p> <pre><code>myObjectCollection.Select(item=&gt;new { Alpha = item.propOne, ...
[ { "answer_id": 543591, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 9, "selected": true, "text": "<p>Have a read through K. Scott Allen's excellent post here:</p>\n\n<p><a href=\"http://odetocode.com/Blogs/scott/archive...
2009/02/12
[ "https://Stackoverflow.com/questions/543482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18071/" ]
So I have a collection of objects. The exact type isn't important. From it I want to extract all the unique pairs of a pair of particular properties, thusly: ``` myObjectCollection.Select(item=>new { Alpha = item.propOne, ...
Have a read through K. Scott Allen's excellent post here: [And Equality for All ... Anonymous Types](http://odetocode.com/Blogs/scott/archive/2008/03/25/11916.aspx) The short answer (and I quote): > > Turns out the C# compiler overrides > Equals and GetHashCode for anonymous > types. The implementation of the two...
543,502
<p>[This is a bit of an unusual problem, I know...]</p> <p>What I need is a script that will change every unique id value to new one in our database. The problem is that we have configuration tables that can be exported between instances of our software which is id-sensitive (clobbering existing ids). Years ago, we se...
[ { "answer_id": 543665, "author": "WW.", "author_id": 14663, "author_profile": "https://Stackoverflow.com/users/14663", "pm_score": -1, "selected": false, "text": "<p>Why don't you use negative numbers for your standard configuration values and continue to use positive numbers for other t...
2009/02/12
[ "https://Stackoverflow.com/questions/543502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37193/" ]
[This is a bit of an unusual problem, I know...] What I need is a script that will change every unique id value to new one in our database. The problem is that we have configuration tables that can be exported between instances of our software which is id-sensitive (clobbering existing ids). Years ago, we set up a "wi...
Here we go with the code for SQL 2005. It's huge, it's hacky, but it *will* work (except in the case where you have a primary key that is a composite of two other primary keys). If someone can re-write this with MrTelly's faster id addition (which wouldn't require building sql from a cursor for each updated row), then...
543,513
<p>Is there another way to get the last child of a div element other than using <code>div:last-child</code>, which does not work in IE8 at least? </p>
[ { "answer_id": 543544, "author": "TomHastjarjanto", "author_id": 53170, "author_profile": "https://Stackoverflow.com/users/53170", "pm_score": 2, "selected": false, "text": "<p>You can assign a class 'last' programmatically and select that one or use javascript. You might also have a sho...
2009/02/12
[ "https://Stackoverflow.com/questions/543513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49632/" ]
Is there another way to get the last child of a div element other than using `div:last-child`, which does not work in IE8 at least?
In jQuery it's easy: ``` $("div :last-child") ``` In pure CSS it can't be done. Otherwise you're stuck with traversing the DOM in Javascript. Also note the difference: * `"div :last-child"`: every last child of a div; and * `"div:last-child"`: every div that **is** a last child.
543,532
<p>I have a DataGrid whose ItemsSource is bound to a changing Observable Collection. Inside of this collection is a Business Object. Based on some of the values of the Business Object's properties, I would like to be able to modify the color of the text for each item displayed in my DataGrid once the ItemsSource is c...
[ { "answer_id": 543582, "author": "Drew Noakes", "author_id": 24874, "author_profile": "https://Stackoverflow.com/users/24874", "pm_score": 1, "selected": false, "text": "<p>If you want to do this all within the same window, you could use a Grid as the root element and host a login elemen...
2009/02/12
[ "https://Stackoverflow.com/questions/543532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63973/" ]
I have a DataGrid whose ItemsSource is bound to a changing Observable Collection. Inside of this collection is a Business Object. Based on some of the values of the Business Object's properties, I would like to be able to modify the color of the text for each item displayed in my DataGrid once the ItemsSource is create...
Take a look at Josh Smith's article in MSDN magazine (<http://msdn.microsoft.com/en-us/magazine/dd419663.aspx>). He describes an interesting method where you have a content presenter on your main window use data templates to switch out what the window is showing.
543,533
<p>I have a javascript file that reads another file which may contain javascript fragments that need to be eval()-ed. The script fragments are supposed to conform to a strict subset of javascript that limits what they can do and which variables they can change, but I want to know if there is some way to enforce this by...
[ { "answer_id": 543573, "author": "Allen Rice", "author_id": 49885, "author_profile": "https://Stackoverflow.com/users/49885", "pm_score": 2, "selected": false, "text": "<p>You cant limit the scope of eval</p>\n\n<p>btw see <a href=\"https://stackoverflow.com/questions/86513/why-is-using-...
2009/02/12
[ "https://Stackoverflow.com/questions/543533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8078/" ]
I have a javascript file that reads another file which may contain javascript fragments that need to be eval()-ed. The script fragments are supposed to conform to a strict subset of javascript that limits what they can do and which variables they can change, but I want to know if there is some way to enforce this by pr...
**Short answer**: No. If it's in the global scope, it's available to anything. **Long answer**: if you're `eval()`ing untrusted code that *really* wants to read or mess with your execution environment, you're screwed. But if you own and trust all code being executed, including that being `eval()`ed, you can fake it b...
543,534
<p>Why doesn't code like the following catch CTRL-C?</p> <pre><code>MAXVAL = 10000 STEP_INTERVAL = 10 for i in range(1, MAXVAL, STEP_INTERVAL): try: print str(i) except KeyboardInterrupt: break print "done" </code></pre> <p>My expectation is -- if CTRL-C is pressed while program is running, ...
[ { "answer_id": 543628, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>Sounds like the program is done by the time control-c has been hit, but your operating system hasn't finished showing you al...
2009/02/12
[ "https://Stackoverflow.com/questions/543534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63503/" ]
Why doesn't code like the following catch CTRL-C? ``` MAXVAL = 10000 STEP_INTERVAL = 10 for i in range(1, MAXVAL, STEP_INTERVAL): try: print str(i) except KeyboardInterrupt: break print "done" ``` My expectation is -- if CTRL-C is pressed while program is running, `KeyboardInterrupt` is sup...
Sounds like the program is done by the time control-c has been hit, but your operating system hasn't finished showing you all the output. .
543,580
<p>When using SQL, are there any benefits of using <code>=</code> in a <code>WHERE</code> clause instead of <code>LIKE</code>?</p> <p>Without any special operators, <code>LIKE</code> and <code>=</code> are the same, right?</p>
[ { "answer_id": 543593, "author": "Coincoin", "author_id": 42, "author_profile": "https://Stackoverflow.com/users/42", "pm_score": 3, "selected": false, "text": "<p>Using = avoids wildcards and special characters conflicts in the string when you build the query at run time. </p>\n\n<p>Thi...
2009/02/12
[ "https://Stackoverflow.com/questions/543580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/307338/" ]
When using SQL, are there any benefits of using `=` in a `WHERE` clause instead of `LIKE`? Without any special operators, `LIKE` and `=` are the same, right?
Different Operators =================== `LIKE` and `=` are different operators. Most answers here focus on the wildcard support, which is not the only difference between these operators! `=` is a comparison operator that operates on numbers and strings. When comparing strings, the comparison operator compares *whole ...
543,584
<p>I'm trying to learn advanced sql and how to use system queries (sql server). The below query is a little confusing.</p> <pre><code>CREATE PROC dbo.ShowHierarchy ( @Root int ) AS BEGIN SET NOCOUNT ON DECLARE @EmpID int, @EmpName varchar(30) SET @EmpName = (SELECT EmpName FROM dbo.Emp WHERE EmpID = @...
[ { "answer_id": 543622, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>Every time the query runs, how is the @EmpId parameter incremented? Does it do itself?</p>\n</blockquot...
2009/02/12
[ "https://Stackoverflow.com/questions/543584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
I'm trying to learn advanced sql and how to use system queries (sql server). The below query is a little confusing. ``` CREATE PROC dbo.ShowHierarchy ( @Root int ) AS BEGIN SET NOCOUNT ON DECLARE @EmpID int, @EmpName varchar(30) SET @EmpName = (SELECT EmpName FROM dbo.Emp WHERE EmpID = @Root) PRIN...
> > Every time the query runs, how is the @EmpId parameter incremented? Does it do itself? > > > This one: ``` SET @EmpID = (SELECT MIN(EmpID) FROM dbo.Emp WHERE MgrID = @Root AND EmpID > @EmpID) ``` selects minimal `EmpID` that is greater than the one already selected, and assigns it to the `@EmpID`. Of cours...
543,587
<p>Why would the database be hit to find a record that is already represented in the ObjectContext?</p> <p>So here's what I thought would happen when you query:</p> <p><code> SiteUser someUser = context.SiteUser.Where(role => role.UserID == 1).ToList()[0]; </code></p> <p>Junk example but the idea is that I want t...
[ { "answer_id": 553668, "author": "GregD", "author_id": 38317, "author_profile": "https://Stackoverflow.com/users/38317", "pm_score": 1, "selected": false, "text": "<p>If I understand your question, this should answer it:</p>\n\n<blockquote>\n <p>Actually, the way the entity framework\n ...
2009/02/12
[ "https://Stackoverflow.com/questions/543587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21691/" ]
Why would the database be hit to find a record that is already represented in the ObjectContext? So here's what I thought would happen when you query: `SiteUser someUser = context.SiteUser.Where(role => role.UserID == 1).ToList()[0];` Junk example but the idea is that I want to get a user from the table with the id ...
context.SiteUser is an property of type ObjectQuery. When you execute an ObjectQuery, it will *always* hit the backing store. That's what they do. If you don't want to execute a database query, then don't use an ObjectQuery. It sounds like what you really want is a function which says, "If the entity is already materi...
543,588
<p>When running tests in Ruby's unit::test framework, is there a really easy way to specify, from the command-line, that only one test should be run (that is, specify the test class and test member variable)? If not, is there another framework that has this feature? </p>
[ { "answer_id": 543613, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 4, "selected": true, "text": "<pre><code>ruby /path/to/foo_test.rb --name test_should_do_something_really_spiffy\n</code></pre>\n\n<p>That will call t...
2009/02/12
[ "https://Stackoverflow.com/questions/543588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56279/" ]
When running tests in Ruby's unit::test framework, is there a really easy way to specify, from the command-line, that only one test should be run (that is, specify the test class and test member variable)? If not, is there another framework that has this feature?
``` ruby /path/to/foo_test.rb --name test_should_do_something_really_spiffy ``` That will call the test defined by the method `test_should_do_something_really_spiffy` in that file. EDIT: That's for the `Test::Unit` framework that most ruby tests are written with. I am assuming you meant the same.
543,612
<p>I searched for a few days now but didn't find a solution. So here is my scenario:</p> <p>I have a DetailView with a DataBindung to a database and DefaultMode set to "<em>Insert</em>" as a input-form for a new db-entry. One field in this DetailsView is a TemplateField with a InsertItemTemplate containing a DropDownL...
[ { "answer_id": 543679, "author": "notnot", "author_id": 65184, "author_profile": "https://Stackoverflow.com/users/65184", "pm_score": 0, "selected": false, "text": "<p>Are you ever inserting more than one row ata a time? I'd like to back up a step and ask why it is you need to have the i...
2009/02/12
[ "https://Stackoverflow.com/questions/543612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5703/" ]
I searched for a few days now but didn't find a solution. So here is my scenario: I have a DetailView with a DataBindung to a database and DefaultMode set to "*Insert*" as a input-form for a new db-entry. One field in this DetailsView is a TemplateField with a InsertItemTemplate containing a DropDownList. This DropDow...
You can use this syntax to access the ddl without writing code: ``` <InsertParameters> <asp:ControlParameter ControlID="DetailsView1$DropDownList1" Name="DropDownList1" PropertyName="SelectedValue" Type="String" /> </InsertParameters> ``` or from the DataSource\_Inserting event and not the DetailsView\_ItemInserting...
543,621
<p>My objective is to write a copy script which moves files from one directory, "d:\aa1", to "d:\aa2" up to a specified size of another directory, "d:\bbb". In other words... I'd like it to copy all files from "d:\aa1" to "d:\aa2" until the size of "d:\aa1" is the same size or less than "d:\bbb".</p> <p>So far I have ...
[ { "answer_id": 543708, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 2, "selected": false, "text": "<pre><code>Get-ChildItem -path d:\\aa1 `\n| % {if (((Get-ChildItem d:\\aa2 `\n| Measure-Object -Property Length -Sum)....
2009/02/12
[ "https://Stackoverflow.com/questions/543621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18853/" ]
My objective is to write a copy script which moves files from one directory, "d:\aa1", to "d:\aa2" up to a specified size of another directory, "d:\bbb". In other words... I'd like it to copy all files from "d:\aa1" to "d:\aa2" until the size of "d:\aa1" is the same size or less than "d:\bbb". So far I have ``` $lmt...
``` Get-ChildItem -path d:\aa1 ` | % {if (((Get-ChildItem d:\aa2 ` | Measure-Object -Property Length -Sum).Sum + $_.Length) ` -lt (Get-ChildItem d:\bbb | Measure-Object -Property Length -Sum).Sum) ` {Move-Item $_.FullName d:\aa2}} ```
543,639
<p>Hi all I have a horrid database I gotta work with and linq to sql is the option im taking to retrieve data from. anywho im trying to reuse a function by throwing in a different table name based on a user selection and there is no way to my knowledge to modify the TEntity or Table&lt;> in a DataContext Query.</p> <p...
[ { "answer_id": 547411, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 3, "selected": true, "text": "<p>You can call the ExecuteQuery method on the DataContext instance. You will want to call the overload that takes a Typ...
2009/02/12
[ "https://Stackoverflow.com/questions/543639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24130/" ]
Hi all I have a horrid database I gotta work with and linq to sql is the option im taking to retrieve data from. anywho im trying to reuse a function by throwing in a different table name based on a user selection and there is no way to my knowledge to modify the TEntity or Table<> in a DataContext Query. This is my c...
You can call the ExecuteQuery method on the DataContext instance. You will want to call the overload that takes a Type instance, outlined here: <http://msdn.microsoft.com/en-us/library/bb534292.aspx> Assuming that you have a type that is attributed correctly for the table, passing that Type instance for that type and...
543,699
<p><strong>HELP!</strong> I just setup a virtual host for two sites that have a lot of traffic and I think I just messed something up! Here is the end of my <strong>httpd.conf</strong>:</p> <pre><code>NameVirtualHost * &lt;VirtualHost *&gt; ServerName www.mydomain.com DocumentRoot /var/www/html &lt;/VirtualHost&gt; &...
[ { "answer_id": 543728, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 3, "selected": true, "text": "<p>Instead of adding the third virtual host, add</p>\n\n<pre><code>ServerAlias mydomain2.com\n</code></pre>\n\n<p>to the se...
2009/02/12
[ "https://Stackoverflow.com/questions/543699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51649/" ]
**HELP!** I just setup a virtual host for two sites that have a lot of traffic and I think I just messed something up! Here is the end of my **httpd.conf**: ``` NameVirtualHost * <VirtualHost *> ServerName www.mydomain.com DocumentRoot /var/www/html </VirtualHost> <VirtualHost *> ServerName www.mydomain2.com Document...
Instead of adding the third virtual host, add ``` ServerAlias mydomain2.com ``` to the second one. So your entire configuration would be basically this: ``` NameVirtualHost * <VirtualHost *> ServerName www.mydomain.com DocumentRoot /var/www/html </VirtualHost> <VirtualHost *> ServerName www.mydomain2.c...
543,703
<p>I'm making a template that is relying on a lot on a tabbed interface and in order to make it a bit more intuitive, I want to make sure that a user can click anywhere in the tab in order to activate it, instead of having to click the text inside the tab. In order to achive this, I'm currently doing this:</p> <pre><c...
[ { "answer_id": 543714, "author": "John Rasch", "author_id": 44765, "author_profile": "https://Stackoverflow.com/users/44765", "pm_score": 0, "selected": false, "text": "<p>Since you're opening up a new window, this is about as efficient as you're going to get, unless you want to put it i...
2009/02/12
[ "https://Stackoverflow.com/questions/543703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29291/" ]
I'm making a template that is relying on a lot on a tabbed interface and in order to make it a bit more intuitive, I want to make sure that a user can click anywhere in the tab in order to activate it, instead of having to click the text inside the tab. In order to achive this, I'm currently doing this: ``` <div class...
It would be more accessible if you did this: ``` <div class="tab"> <a href="..." style="display: block;">tab text</a> </div> ``` Setting the `<a>` to `block` lets it fill the width, and you can give it height, padding etc. just like a `<div>`. You could even do away with the `<div>` entirely. ``` <a href="..." ...
543,737
<p>According to the <a href="http://www.delorie.com/gnu/docs/screen/screen_12.html" rel="noreferrer">docs for the Unix "screen" command</a>, you can configure it in .screenrc to start with a bunch of default screens, each running a command that you specify.</p> <p>Here's my cofig:</p> <pre><code># Default screens scr...
[ { "answer_id": 543786, "author": "chaos", "author_id": 47529, "author_profile": "https://Stackoverflow.com/users/47529", "pm_score": 5, "selected": true, "text": "<p>Your program is being run (well, except the cd), it's just that it's being run without a parent shell, so as soon as it co...
2009/02/12
[ "https://Stackoverflow.com/questions/543737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
According to the [docs for the Unix "screen" command](http://www.delorie.com/gnu/docs/screen/screen_12.html), you can configure it in .screenrc to start with a bunch of default screens, each running a command that you specify. Here's my cofig: ``` # Default screens screen -t "shell_0" 1 screen -t "autotest" 2 cd ~/p...
Your program is being run (well, except the cd), it's just that it's being run without a parent shell, so as soon as it completes, it exits and you're done. You could do: ``` screen -t "autotest" 2 bash -c 'cd ~/project/contactdb ; autotest' ``` Spawns two shells, but life will probably go on.
543,750
<p>I am using the format ToString("0,0") to display a number like <pre>5000 as 5,000</pre> but if the number is 0 - 9, it displays 01, 02, 03, etc. Does anyone know the correct syntax so it does not display the leading 0?</p> <p>Thanks, XaiSoft</p>
[ { "answer_id": 543758, "author": "juan", "author_id": 1782, "author_profile": "https://Stackoverflow.com/users/1782", "pm_score": 5, "selected": true, "text": "<pre><code>ToString(\"#,0\")\n</code></pre>\n\n<p>Also, <a href=\"http://acodingfool.typepad.com/blog/dotnet-string-formatting-c...
2009/02/12
[ "https://Stackoverflow.com/questions/543750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
I am using the format ToString("0,0") to display a number like ``` 5000 as 5,000 ``` but if the number is 0 - 9, it displays 01, 02, 03, etc. Does anyone know the correct syntax so it does not display the leading 0? Thanks, XaiSoft
``` ToString("#,0") ``` Also, [this](http://acodingfool.typepad.com/blog/dotnet-string-formatting-cheat-sheet.html) may help you further
543,760
<p>Hiding a DIV would be easy enough in Javascript, but is there some Rails-y way to do it? I can think of some ways to do it by calling Javascript from a partial (.erb), of course, but I'd prefer not to write any Javascript at all. Possible?</p> <p><strong>Edit:</strong> The page is loaded and I would like to hide th...
[ { "answer_id": 543788, "author": "seanb", "author_id": 3354, "author_profile": "https://Stackoverflow.com/users/3354", "pm_score": 1, "selected": false, "text": "<p>Don't really know rails, but can you just output something like style=\"display:none;\" into the div tag?</p>\n" }, { ...
2009/02/12
[ "https://Stackoverflow.com/questions/543760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
Hiding a DIV would be easy enough in Javascript, but is there some Rails-y way to do it? I can think of some ways to do it by calling Javascript from a partial (.erb), of course, but I'd prefer not to write any Javascript at all. Possible? **Edit:** The page is loaded and I would like to hide the DIV **after** (well, ...
Or, right in your view: For a class-specified div: ``` <%= link_to_function "Toggle", "$('.some_div').toggle()" %> ``` For an ID-specified div: ``` <%= link_to_function "Toggle", "$('#some_div').toggle()" %> ``` (notice the hash-mark) Added period to class specific div and hash to id specific div
543,769
<p>my site is now going to start allowing two different types of users to sign up... </p> <ol> <li>normal people </li> <li>companies </li> </ol> <p>the two will be able to do all the same things on the site, but their profiles will look different, and im sure they will want to store different types of information ...
[ { "answer_id": 543787, "author": "Stephen", "author_id": 38714, "author_profile": "https://Stackoverflow.com/users/38714", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://www.agiledata.org/essays/dataNormalization.html\" rel=\"nofollow noreferrer\">This link</a> explains so...
2009/02/12
[ "https://Stackoverflow.com/questions/543769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54408/" ]
my site is now going to start allowing two different types of users to sign up... 1. normal people 2. companies the two will be able to do all the same things on the site, but their profiles will look different, and im sure they will want to store different types of information about themselves. my question is: sho...
[This link](http://www.agiledata.org/essays/dataNormalization.html) explains some best database practices. I'd create an "Accounts" table with a UID, with common information between the two stored there, and which type of account it is. Then a "Companies" table with company specific information, using the same UID a...
543,775
<p>This semester I'm teaching a class at a local university. Thus far, I've had the students turn in their programming assignments by emailing them to me. But there is a lot of hassle when pulling 20 solutions out of emails. </p> <p>Has anyone ever used a source control tool to have students turn projects in? What did...
[ { "answer_id": 543808, "author": "Tim", "author_id": 10755, "author_profile": "https://Stackoverflow.com/users/10755", "pm_score": 1, "selected": false, "text": "<p>I think a common way is to create directories for ftp uploads. Some cron job can check for submissions and automatically r...
2009/02/12
[ "https://Stackoverflow.com/questions/543775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26339/" ]
This semester I'm teaching a class at a local university. Thus far, I've had the students turn in their programming assignments by emailing them to me. But there is a lot of hassle when pulling 20 solutions out of emails. Has anyone ever used a source control tool to have students turn projects in? What did you use a...
At my university, the school of Computer and Information Science runs a student CVS server. Each subject (that chooses to use it) gets a repository, with each student enrolled in the subject getting a folder in there. The admin accounts obviously get access to the whole lot, while each student can only checkout their o...
543,779
<p>I'm working on a Mac, with some fairly old files. Different files were created by different programs, so some of them end with <code>\r</code> (Mac) and some with <code>\n</code> (Unix). I want to be able to run commands like diff, grep, etc. on these files, but the ones that have <code>\r</code> are treated as one ...
[ { "answer_id": 543796, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 4, "selected": false, "text": "<p>If you use <code><strong>diff -w</strong></code> it will ignore whitespace in the files, which is probably sufficient for y...
2009/02/12
[ "https://Stackoverflow.com/questions/543779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53491/" ]
I'm working on a Mac, with some fairly old files. Different files were created by different programs, so some of them end with `\r` (Mac) and some with `\n` (Unix). I want to be able to run commands like diff, grep, etc. on these files, but the ones that have `\r` are treated as one giant line. Are there versions of [d...
As Jay said, Diff'nPatch seems what you are looking for. Alternatively you can convert all your '\r' line endings in '\n' in a single command like this: ``` sed -ie 's/\r/\n/' filename ``` or ``` find . | xargs -n1 sed -ie 's/\r/\n/' ``` (You may want to filter the list of files in some way in the latter case or...
543,790
<p>I'm <em>kinda</em> new to using Rails, and an app I am working on is progressing well - however I'm looking though the generated HTML and noticed things like...</p> <pre><code>&lt;script type="text/javascript"&gt; //&lt;![CDATA[ Droppables.add(...); //]]&gt; &lt;/script&gt; </code></pre> <p>Sprinkled around the HT...
[ { "answer_id": 543822, "author": "TomHastjarjanto", "author_id": 53170, "author_profile": "https://Stackoverflow.com/users/53170", "pm_score": 4, "selected": true, "text": "<p>Well if you really want to use best practices...Do not use inline javascript. Keep your HTML, CSS and Javascript...
2009/02/12
[ "https://Stackoverflow.com/questions/543790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18434/" ]
I'm *kinda* new to using Rails, and an app I am working on is progressing well - however I'm looking though the generated HTML and noticed things like... ``` <script type="text/javascript"> //<![CDATA[ Droppables.add(...); //]]> </script> ``` Sprinkled around the HTML, which of course matches up with places where I ...
Well if you really want to use best practices...Do not use inline javascript. Keep your HTML, CSS and Javascript clean and seperated from eachother. Ideally the html file should be usable without CSS and javascript. The cleanest way, imo, is to just build your app using plain html/css, and enhance it with unobtrusive ...
543,854
<p>In my web app, I use the <strong>onkeydown</strong> event to capture key strokes.</p> <p>For example, I capture the 'j' key to animate a scroll down the page (and do some other stuff meanwhile).</p> <p>My problem is the user might keep the 'j' key down to scroll further down the page (this is equivalent to fast mu...
[ { "answer_id": 543873, "author": "JMD", "author_id": 56793, "author_profile": "https://Stackoverflow.com/users/56793", "pm_score": 1, "selected": false, "text": "<p>Rather than trying to stack up the animations, you could start an animation on keyDown, and if at the end of the animation ...
2009/02/12
[ "https://Stackoverflow.com/questions/543854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1011/" ]
In my web app, I use the **onkeydown** event to capture key strokes. For example, I capture the 'j' key to animate a scroll down the page (and do some other stuff meanwhile). My problem is the user might keep the 'j' key down to scroll further down the page (this is equivalent to fast multiple key strokes). In my a...
Building on [@JMD](https://stackoverflow.com/users/56793/jmd): ``` var animate = false; function startanimation() { animate = true; runanimation(); } function stopanimation() { animate = false; } function runanimation() { if ( animation_over ) { if ( !animate ) { return; } return s...
543,857
<p>I have a bunch of input elements that have a particular substring in their IDs. Using javascript, is there a way to get these elements as an array? I wouldn't know the full ID - only the substring.</p> <p>Is this any simpler if I use JQuery?</p>
[ { "answer_id": 543862, "author": "yoavf", "author_id": 1011, "author_profile": "https://Stackoverflow.com/users/1011", "pm_score": 1, "selected": true, "text": "<p>Quite easy with jQuery. Example:</p>\n\n<pre><code>$(\"li[id^='comment']\") \n</code></pre>\n\n<p>Select all \"li\" where id...
2009/02/12
[ "https://Stackoverflow.com/questions/543857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a bunch of input elements that have a particular substring in their IDs. Using javascript, is there a way to get these elements as an array? I wouldn't know the full ID - only the substring. Is this any simpler if I use JQuery?
Quite easy with jQuery. Example: ``` $("li[id^='comment']") ``` Select all "li" where id starts with "comment". **EDIT** To get those into an array: ``` var myArray = new Array; $("li[id^='comment']").each(function() { var thisId = $(this).attr("id"); myArray.push(thisId); }); ```
543,864
<p>What's my best bet for implementing a simple chat client (2-person) in an ASP.NET 1.1 application? I'm using ExtJS for the front-end so if it integrates well with that it would be great.</p>
[ { "answer_id": 543862, "author": "yoavf", "author_id": 1011, "author_profile": "https://Stackoverflow.com/users/1011", "pm_score": 1, "selected": true, "text": "<p>Quite easy with jQuery. Example:</p>\n\n<pre><code>$(\"li[id^='comment']\") \n</code></pre>\n\n<p>Select all \"li\" where id...
2009/02/12
[ "https://Stackoverflow.com/questions/543864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47110/" ]
What's my best bet for implementing a simple chat client (2-person) in an ASP.NET 1.1 application? I'm using ExtJS for the front-end so if it integrates well with that it would be great.
Quite easy with jQuery. Example: ``` $("li[id^='comment']") ``` Select all "li" where id starts with "comment". **EDIT** To get those into an array: ``` var myArray = new Array; $("li[id^='comment']").each(function() { var thisId = $(this).attr("id"); myArray.push(thisId); }); ```
543,868
<p>The following code produces the output "xyz" </p> <pre><code>a = %w{x y z} print a.to_s </code></pre> <p>Is there an option that can be added to the block to allow spaces to be added?</p> <p>For example, I thought that by changing the code to this I might be able to space-separate the elements to produce an outp...
[ { "answer_id": 543893, "author": "Andrew Vit", "author_id": 61439, "author_profile": "https://Stackoverflow.com/users/61439", "pm_score": 2, "selected": false, "text": "<p>Don't use <code>%w</code> for this--it's a shortcut for when you want to split an array from words. Otherwise, use t...
2009/02/12
[ "https://Stackoverflow.com/questions/543868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The following code produces the output "xyz" ``` a = %w{x y z} print a.to_s ``` Is there an option that can be added to the block to allow spaces to be added? For example, I thought that by changing the code to this I might be able to space-separate the elements to produce an output of "x y z" ``` a = %w{"x " "y...
``` a = ["xyz"].split("").join(" ") ``` or ``` a = ["x","y","z"].join(" ") ``` or ``` a = %w(x y z).join(" ") ```
543,896
<p>I'm trying to access a web service secured by a certificate. The security is setup on IIS and the web service is behind it.</p> <p>I don't think WS-SECURITY will do this type of authentication. Is there any way to pass the client certificate when you call the web service?</p> <p>I'm just getting an IIS Error Page ...
[ { "answer_id": 577618, "author": "Chris Dail", "author_id": 5077, "author_profile": "https://Stackoverflow.com/users/5077", "pm_score": 4, "selected": true, "text": "<p>Yes, this is possible using CXF. You will need to set up the client conduit. You can specify the keystore that contains...
2009/02/12
[ "https://Stackoverflow.com/questions/543896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
I'm trying to access a web service secured by a certificate. The security is setup on IIS and the web service is behind it. I don't think WS-SECURITY will do this type of authentication. Is there any way to pass the client certificate when you call the web service? I'm just getting an IIS Error Page that says "The pa...
Yes, this is possible using CXF. You will need to set up the client conduit. You can specify the keystore that contains the certificates that will allow you to access the web service in IIS. As long as the certificate you are using here is a known allowed client in IIS, you should be ok. ``` <http:conduit name="{http:...
543,897
<p>I'm trying to figure out a way to automatically cast something to an Action or Func and the best I can come up with is something like this:</p> <pre><code>[TestFixture] public class ExecutionTest { public void BadMethod() { throw new Exception("Something bad happened"); } [Test] public ...
[ { "answer_id": 543977, "author": "Coincoin", "author_id": 42, "author_profile": "https://Stackoverflow.com/users/42", "pm_score": 4, "selected": true, "text": "<p>In C#, when you use the method name without parenthesis, it's called a method group and it has no representation other than a...
2009/02/12
[ "https://Stackoverflow.com/questions/543897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to figure out a way to automatically cast something to an Action or Func and the best I can come up with is something like this: ``` [TestFixture] public class ExecutionTest { public void BadMethod() { throw new Exception("Something bad happened"); } [Test] public void TestBadMe...
In C#, when you use the method name without parenthesis, it's called a method group and it has no representation other than at compile time. A method group can represent more than one method (because of overloads and overrides), therefore to implicitly identify which method is needed, a target delegate type must be pro...
543,901
<p>At a previous job they had a debug mode that would highlight struts tiles in the browser so you could tell what each tile was doing and the tile's filename. This was enormously helpful for when you are lost in a forest of nested tiles. Now that I'm at a new struts place, I've been trying to figure out how to imple...
[ { "answer_id": 593102, "author": "Michael Rush", "author_id": 57624, "author_profile": "https://Stackoverflow.com/users/57624", "pm_score": 1, "selected": false, "text": "<p>the following code works for me (in a jsp):</p>\n\n<pre><code> Object nestedTilePath = request.getAttribute(\"ja...
2009/02/12
[ "https://Stackoverflow.com/questions/543901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11015/" ]
At a previous job they had a debug mode that would highlight struts tiles in the browser so you could tell what each tile was doing and the tile's filename. This was enormously helpful for when you are lost in a forest of nested tiles. Now that I'm at a new struts place, I've been trying to figure out how to implement ...
the following code works for me (in a jsp): ``` Object nestedTilePath = request.getAttribute("javax.servlet.include.request_uri"); String thePath; if (nestedTilePath != null){ thePath = nestedTilePath.toString(); } else { thePath = request.getRequestURI(); } out.println(application.getRealP...
543,949
<p><em>This question is similar to <a href="https://stackoverflow.com/questions/259673/what-is-the-best-way-to-share-delphi-source-files-among-projects">this one</a>, but not a duplicate because I'm asking about issues not discussed in that question.</em></p> <p>I have a client-server project in Delphi 7 with the foll...
[ { "answer_id": 544150, "author": "Cesar Romero", "author_id": 36875, "author_profile": "https://Stackoverflow.com/users/36875", "pm_score": 2, "selected": false, "text": "<p>I usually create a package with all shared unit, and just use the units.\nIf you do not explicitly mark \"Build wi...
2009/02/12
[ "https://Stackoverflow.com/questions/543949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62/" ]
*This question is similar to [this one](https://stackoverflow.com/questions/259673/what-is-the-best-way-to-share-delphi-source-files-among-projects), but not a duplicate because I'm asking about issues not discussed in that question.* I have a client-server project in Delphi 7 with the following directory structure: ...
Sharing units between applications always carries the risk of incompatible changes done in one application that breaks the other. On the other hand, making copies of these units is even worse, so your approcach of moving them to their own subdirectory at least adds a psychological barrier to changing them without consi...
543,955
<p>I have found an extension method that handles sorting and paging for <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" rel="nofollow noreferrer">LINQ</a>. While this works well, I am trying to see if there are some other ways I can use this.</p> <p>At present, the code for the <a href="http://en.wiki...
[ { "answer_id": 544879, "author": "Michael La Voie", "author_id": 65843, "author_profile": "https://Stackoverflow.com/users/65843", "pm_score": 4, "selected": true, "text": "<p>I'm not exactly sure what you're asking, but I believe it's something that I have looked into myself. If you wo...
2009/02/12
[ "https://Stackoverflow.com/questions/543955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25361/" ]
I have found an extension method that handles sorting and paging for [LINQ](http://en.wikipedia.org/wiki/Language_Integrated_Query). While this works well, I am trying to see if there are some other ways I can use this. At present, the code for the [extension method](http://en.wikipedia.org/wiki/Extension_method) is a...
I'm not exactly sure what you're asking, but I believe it's something that I have looked into myself. If you would like to know how to dynamically sort your results based on a string, rather than a proper LINQ expression, then you're in luck. Scott Guthrie published a great [article](http://weblogs.asp.net/scottgu/arc...
543,968
<p>Is there a problem with this type of implementation to wait for a batch of threads to complete before moving on, given the following circumstances?:</p> <ul> <li>CCR or PFX cannot be used.</li> <li>Customer.Prices collection and newCustomer are NOT being mutated.</li> <li>CloneCustomerPrices performs a deep copy on...
[ { "answer_id": 543972, "author": "Robin Day", "author_id": 40655, "author_profile": "https://Stackoverflow.com/users/40655", "pm_score": 3, "selected": false, "text": "<p>They take DISTINCT as all aggregates do, however, the fact that there might be more than one of the values is irrelev...
2009/02/12
[ "https://Stackoverflow.com/questions/543968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32120/" ]
Is there a problem with this type of implementation to wait for a batch of threads to complete before moving on, given the following circumstances?: * CCR or PFX cannot be used. * Customer.Prices collection and newCustomer are NOT being mutated. * CloneCustomerPrices performs a deep copy on each of the prices in Custo...
As far as I know, the SQL92 standard has Five aggregate functions defined. Those five are avg, count, max, min, and sum. Coincidentally\*, those all accept the DISTINCT keyword. \*and by that I mean "not coincidentally"
543,971
<p>I <a href="https://i.stack.imgur.com/5CduL.png" rel="nofollow noreferrer">added a new ADO.Net Entity Data Model</a> into my project and used the <a href="https://i.stack.imgur.com/c4Pju.png" rel="nofollow noreferrer">Update Wizard</a> to add tables into the model. Five of the selected tables were added to the desig...
[ { "answer_id": 546077, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 7, "selected": true, "text": "<p>The design surface is different from the entity model. It is possible to have a table in the mapping in your EDMX whi...
2009/02/12
[ "https://Stackoverflow.com/questions/543971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23566/" ]
I [added a new ADO.Net Entity Data Model](https://i.stack.imgur.com/5CduL.png) into my project and used the [Update Wizard](https://i.stack.imgur.com/c4Pju.png) to add tables into the model. Five of the selected tables were added to the design surface. Two other tables will not add. I select them in the wizard and clic...
The design surface is different from the entity model. It is possible to have a table in the mapping in your EDMX which does not appear on the design surface. View the file as XML to see if this is the case. In this case, the Update Wizard will not allow you to re-add the tables, since they are already part of the enti...
543,995
<p>Once upon a time, a young, naive engineer thought it would be a good idea to separate out some of the functionality for his app into a COM component, written in C#. Visual studio had all the tools to do that, right? .NET was practically made for this, right? HA! He said, this will be easy. I'll have decent sepa...
[ { "answer_id": 544572, "author": "Wim Coenen", "author_id": 52626, "author_profile": "https://Stackoverflow.com/users/52626", "pm_score": 2, "selected": false, "text": "<p>To extract the COM information, tallow will use the <a href=\"http://msdn.microsoft.com/en-us/library/tzat5yw6(VS.71...
2009/02/12
[ "https://Stackoverflow.com/questions/543995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18097/" ]
Once upon a time, a young, naive engineer thought it would be a good idea to separate out some of the functionality for his app into a COM component, written in C#. Visual studio had all the tools to do that, right? .NET was practically made for this, right? HA! He said, this will be easy. I'll have decent separation o...
You should use Heat (WIX 3.0) located in the bin directory of the version you are using. Have a look at this [blog](http://installing.blogspot.com/2006/04/heatexe-making-setup-easier.html "heat.exe - making setup easier") post, we use it here to register all our COM objects, by creating a wix fragment... something lik...
544,010
<p>What's the difference between <code>&lt;div class=""&gt;</code> and <code>&lt;div id=""&gt;</code> when it comes to CSS? Is it alright to use <code>&lt;div id=""&gt;</code>?</p> <p>I see different developers doing this in both ways, and since I'm self taught, I've never really figured it out.</p>
[ { "answer_id": 544017, "author": "Luc M", "author_id": 14673, "author_profile": "https://Stackoverflow.com/users/14673", "pm_score": 3, "selected": false, "text": "<p>An id must be unique in the whole page.</p>\n\n<p>A class may apply to many elements.</p>\n\n<p>Sometimes, it's a good id...
2009/02/12
[ "https://Stackoverflow.com/questions/544010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54408/" ]
What's the difference between `<div class="">` and `<div id="">` when it comes to CSS? Is it alright to use `<div id="">`? I see different developers doing this in both ways, and since I'm self taught, I've never really figured it out.
`ids` must be unique where as `class` can be applied to many things. In CSS, `id`s look like `#elementID` and `class` elements look like `.someClass` In general, use `id` whenever you want to refer to a specific element and `class` when you have a number of things that are all alike. For instance, common `id` elements...
544,031
<p>In my Ruby app, I've used the following method and regular expression to remove all HTML tags from a string:</p> <pre><code>str.gsub(/&lt;\/?[^&gt;]*&gt;/,"") </code></pre> <p>This regular expression did just about all I was expecting it to, except it caused all quotation marks to be transformed into <code>&amp;#8...
[ { "answer_id": 544060, "author": "Tim", "author_id": 35767, "author_profile": "https://Stackoverflow.com/users/35767", "pm_score": -1, "selected": false, "text": "<p>You could use a multi-pass system to get the results you are looking for. </p>\n\n<p>After running your regular expressio...
2009/02/12
[ "https://Stackoverflow.com/questions/544031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2293/" ]
In my Ruby app, I've used the following method and regular expression to remove all HTML tags from a string: ``` str.gsub(/<\/?[^>]*>/,"") ``` This regular expression did just about all I was expecting it to, except it caused all quotation marks to be transformed into `&#8220;` and all single quotes to be changed to...
Use CGI::unescapeHTML after you perform your regular expression substitution: ``` CGI::unescapeHTML(str.gsub(/<\/?[^>]*>/,"")) ``` See <http://www.ruby-doc.org/core/classes/CGI.html#M000547> In the above code snippet, gsub removes all HTML tags. Then, unescapeHTML() reverts all HTML entities (such as <, &#8220) to ...
544,037
<p>I've inherited the code below but I'm puzzled as the code works just fine but I'm not convinced it's correct. I've not used LIKE before so I can't decide if I should bother changing this. How does this look to you?</p> <p>The code is for a filter in a db it checks if X value contains Y value, find X* in X (e.g. Mat...
[ { "answer_id": 544045, "author": "ermau", "author_id": 26908, "author_profile": "https://Stackoverflow.com/users/26908", "pm_score": 1, "selected": false, "text": "<p>While this looks like it should work for the intended purpose, you should really be escaping the text thats appended into...
2009/02/12
[ "https://Stackoverflow.com/questions/544037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've inherited the code below but I'm puzzled as the code works just fine but I'm not convinced it's correct. I've not used LIKE before so I can't decide if I should bother changing this. How does this look to you? The code is for a filter in a db it checks if X value contains Y value, find X\* in X (e.g. Match would ...
While this looks like it should work for the intended purpose, you should really be escaping the text thats appended into what's presumably a SQL string.
544,038
<p>I've created the following RESTful WCF service, which works just fine when running it in VS. </p> <pre><code>[OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/sales/start={start}&amp;end={end}")] List&lt;Sales&gt; GetSalesByDate(string start, string end); </code></pre> <p>How...
[ { "answer_id": 544655, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 0, "selected": false, "text": "<p>I bet it is that the dev machine has SP1 and the server does not.</p>\n\n<p><a href=\"http://blogs.msdn.com/endpoint/arch...
2009/02/12
[ "https://Stackoverflow.com/questions/544038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56864/" ]
I've created the following RESTful WCF service, which works just fine when running it in VS. ``` [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/sales/start={start}&end={end}")] List<Sales> GetSalesByDate(string start, string end); ``` However, when deploying this to my test...
It turns out `/sales/start={start}&end={end}` is not a valid Uri (duh!). After a little trial and error I finally figured this out. Tweaking the UriTemplate with a '?' solved the problem. ``` [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/sales/?start={start}&end={end}")] List...
544,041
<p>The following error occurs in make, while trying to do incremental builds:</p> <blockquote> <p>make[2]: execvp: C:/path/to/compiler.exe: Message too long</p> </blockquote> <p>I suspect my problem here is the argument length for execvp. Any idea what that limit is? How would one go about changing that?</p> ...
[ { "answer_id": 544655, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 0, "selected": false, "text": "<p>I bet it is that the dev machine has SP1 and the server does not.</p>\n\n<p><a href=\"http://blogs.msdn.com/endpoint/arch...
2009/02/12
[ "https://Stackoverflow.com/questions/544041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37834/" ]
The following error occurs in make, while trying to do incremental builds: > > make[2]: execvp: C:/path/to/compiler.exe: Message too long > > > I suspect my problem here is the argument length for execvp. Any idea what that limit is? How would one go about changing that? Some curious extra information: the same ...
It turns out `/sales/start={start}&end={end}` is not a valid Uri (duh!). After a little trial and error I finally figured this out. Tweaking the UriTemplate with a '?' solved the problem. ``` [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/sales/?start={start}&end={end}")] List...
544,050
<p>I recently came across a use of the @import rule on Coda.com. They're actually using to import the main style sheet for the site, specifically the format:</p> <pre><code>&lt;style type="text/css" media="screen"&gt; @import url(./coda.css); &lt;/style&gt; </code></pre> <p>Which will hide the rules from Netscape 3...
[ { "answer_id": 544074, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 4, "selected": false, "text": "<p>None. Using a <code>&lt;link&gt;</code> element also has the advantage of getting rid of the <a href=\"http://blu...
2009/02/12
[ "https://Stackoverflow.com/questions/544050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1169746/" ]
I recently came across a use of the @import rule on Coda.com. They're actually using to import the main style sheet for the site, specifically the format: ``` <style type="text/css" media="screen"> @import url(./coda.css); </style> ``` Which will hide the rules from Netscape 3 and IE 3 and 4. Since a web developme...
For Coda's site, I'd imagine they did that more out of force of habit rather than any pressing technical need. `@import` statements inside of actual CSS files (not in a `<style>` element in HTML) serve many purposes, such as making it easy to swap in and out other CSS files. The Blueprint CSS framework does this to le...
544,075
<p>Suppose my Delphi classes look like this:</p> <pre><code>interface type TMySubInfo = class public Name : string; Date : TDateTime; Age : Integer; end; TMyInfo = class public Name : string; SubInfo : array of TMySubInfo; destructor Destroy; overr...
[ { "answer_id": 544098, "author": "dwc", "author_id": 57301, "author_profile": "https://Stackoverflow.com/users/57301", "pm_score": 2, "selected": false, "text": "<p>For every new there should be a free.</p>\n" }, { "answer_id": 544102, "author": "Vegar", "author_id": 1195...
2009/02/12
[ "https://Stackoverflow.com/questions/544075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
Suppose my Delphi classes look like this: ``` interface type TMySubInfo = class public Name : string; Date : TDateTime; Age : Integer; end; TMyInfo = class public Name : string; SubInfo : array of TMySubInfo; destructor Destroy; override; end; ...
You need to loop through and free each created object. You must know, that declaring a array of TMySubInfo doesn't actually create the objects. You have to create them later on. I would use a TList instead for a more dynamic approach. You could even use a TObjectList that can free all its items when the list gets fre...
544,078
<p>Currently in my ASP.Net applications web.config I have an application setting that stores a comma delimited list of mapping values, like the one below. In the code behind I need to perform a lookup on this data based on input values 1, 2, 3 etc. I can either string split it and loop until I find a match, or use Rege...
[ { "answer_id": 544143, "author": "Moose", "author_id": 19032, "author_profile": "https://Stackoverflow.com/users/19032", "pm_score": 0, "selected": false, "text": "<p>Split the string on commas, then each substring on |, store these in a Dictionary and find it by key.</p>\n\n<p>That's ju...
2009/02/12
[ "https://Stackoverflow.com/questions/544078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56753/" ]
Currently in my ASP.Net applications web.config I have an application setting that stores a comma delimited list of mapping values, like the one below. In the code behind I need to perform a lookup on this data based on input values 1, 2, 3 etc. I can either string split it and loop until I find a match, or use Regex t...
If you need to use this lookup frequently and the string in web.config doesn't change very often, then it makes sense to parse the string once into a Dictionary object and store that in the Application or Cache. Lookups from the Dictionary will be lightning fast, especially compared to parsing the string each time. `...
544,079
<p>I'm attempting to draw text to the screen using GLUT in 2d.</p> <p>I want to use glutBitmapString(), can someone show me a simple example of what you have to do to setup and properly use this method in C++ so I can draw an arbitrary string at an (X,Y) position?</p> <pre><code>glutBitmapString(void *font, const uns...
[ { "answer_id": 544107, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 5, "selected": true, "text": "<p>You have to use <a href=\"http://linux.die.net/man/3/glrasterpos\" rel=\"noreferrer\"><code>glRasterPos</code></a>...
2009/02/12
[ "https://Stackoverflow.com/questions/544079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64878/" ]
I'm attempting to draw text to the screen using GLUT in 2d. I want to use glutBitmapString(), can someone show me a simple example of what you have to do to setup and properly use this method in C++ so I can draw an arbitrary string at an (X,Y) position? ``` glutBitmapString(void *font, const unsigned char *string); ...
You have to use [`glRasterPos`](http://linux.die.net/man/3/glrasterpos) to set the raster position before calling `glutBitmapString()`. Note that each call to `glutBitmapString()` advances the raster position, so several consecutive calls will print out the strings one after another. You can also set the text color by ...