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
179,708
<p>Can anybody recommend a good method for determining the Rect of some wrapped text on an iPhone? I've tried all the built-in methods for NSString in the 2.1 SDK to no avail. The size methods never return sizes that allow me to completely fit wrapped text in my custom view.</p> <p>I'm drawing some user customizable...
[ { "answer_id": 179963, "author": "Mike McMaster", "author_id": 544, "author_profile": "https://Stackoverflow.com/users/544", "pm_score": 2, "selected": false, "text": "<p>NSString's sizeWithFont:constrainedToSize: method might be useful:</p>\n\n<pre><code>CGSize sizeForText = [theText si...
2008/10/07
[ "https://Stackoverflow.com/questions/179708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can anybody recommend a good method for determining the Rect of some wrapped text on an iPhone? I've tried all the built-in methods for NSString in the 2.1 SDK to no avail. The size methods never return sizes that allow me to completely fit wrapped text in my custom view. I'm drawing some user customizable text that s...
NSString's sizeWithFont:constrainedToSize: method might be useful: ``` CGSize sizeForText = [theText sizeWithFont:theFont constrainedToSize:CGSizeMake(myMaxWidth, 9999)]; ``` You say you've tried all the size methods, but based on your description, it sounds like what you're looking for.
179,713
<p>How can you change the <code>href</code> attribute (link target) for a hyperlink using jQuery?</p>
[ { "answer_id": 179717, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 12, "selected": true, "text": "<p>Using</p>\n\n<pre><code>$(\"a\").attr(\"href\", \"http://www.google.com/\")\n</code></pre>\n\n<p>will modify the href of all ...
2008/10/07
[ "https://Stackoverflow.com/questions/179713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
How can you change the `href` attribute (link target) for a hyperlink using jQuery?
Using ``` $("a").attr("href", "http://www.google.com/") ``` will modify the href of all hyperlinks to point to Google. You probably want a somewhat more refined selector though. For instance, if you have a mix of link source (hyperlink) and link target (a.k.a. "anchor") anchor tags: ``` <a name="MyLinks"></a> <a hr...
179,723
<p>By that I mean, what do I need to do to have useful assertions in my code?</p> <p>MFC is quite easy, i just use ASSERT(something).</p> <p>What's the non-MFC way?</p> <p><strong>Edit:</strong> Is it possible to stop assert breaking in assert.c rather than than my file which called assert()?</p> <p><strong>Edit:</...
[ { "answer_id": 179733, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 6, "selected": true, "text": "<pre><code>#include &lt;cassert&gt;\n\nassert(something);\n</code></pre>\n\n<p>and for compile-time checking, Boost's stati...
2008/10/07
[ "https://Stackoverflow.com/questions/179723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
By that I mean, what do I need to do to have useful assertions in my code? MFC is quite easy, i just use ASSERT(something). What's the non-MFC way? **Edit:** Is it possible to stop assert breaking in assert.c rather than than my file which called assert()? **Edit:** What's the difference between `<assert.h>` & `<ca...
``` #include <cassert> assert(something); ``` and for compile-time checking, Boost's static asserts are pretty useful: ``` #include <boost/static_assert.hpp> BOOST_STATIC_ASSERT(sizeof(int) == 4); // compile fails if ints aren't 32-bit ```
179,742
<p>VB 2008.</p> <p>I have several text boxes on a form and I want each of them to use the same event handler. I know how to manually wire each one up to the handler, but I'm looking for a more generic way so if I add more text boxes they will automatically be hooked up to the event handler.</p> <p>Ideas?</p> <p>EDIT...
[ { "answer_id": 179771, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>It might be possible with a macro, but otherwise, I a m not aware of anything that would automatically wire an ...
2008/10/07
[ "https://Stackoverflow.com/questions/179742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2441/" ]
VB 2008. I have several text boxes on a form and I want each of them to use the same event handler. I know how to manually wire each one up to the handler, but I'm looking for a more generic way so if I add more text boxes they will automatically be hooked up to the event handler. Ideas? EDIT: Using the C# sample fr...
Do something like this in your form's load event (C#, sorry, but it's easy to translate): ``` private void Form1_Load(object sender, EventArgs e) { foreach (Control ctrl in this.Controls) { if (ctrl is TextBox) { TextBox tb = (TextBox)ctrl; tb.TextChanged += new EventHan...
179,752
<p>Lets say on my page I have this function:</p> <pre><code> function ReturnFoo(bar) { return bar.toString() + "foo"; } </code></pre> <p>Now, I would like to have this called from ASP .NET, hopefully with the ASP .NET AJAX framework, as I am already using it in this codebase (I have already spent the 100k, might...
[ { "answer_id": 179776, "author": "Matt", "author_id": 17759, "author_profile": "https://Stackoverflow.com/users/17759", "pm_score": 0, "selected": false, "text": "<p>I don't see how you expect server-side code to call a client-side function???</p>\n\n<p>AJAX calls are from the client-sid...
2008/10/07
[ "https://Stackoverflow.com/questions/179752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
Lets say on my page I have this function: ``` function ReturnFoo(bar) { return bar.toString() + "foo"; } ``` Now, I would like to have this called from ASP .NET, hopefully with the ASP .NET AJAX framework, as I am already using it in this codebase (I have already spent the 100k, might as well use it). Also, I...
Yeah, this is a difficult one. Using MS Ajax will help you out a bit. You'll need to push in code from the server to call this function upon page load and assign the return value to a hidden field that can be accessed by the server on post back. I must say that this solution sucks, but I don't know another way. Hopefu...
179,779
<p>I am writing code for a search results page that needs to highlight search terms. The terms happen to occur within table cells (the app is iterating through GridView Row Cells), and these table cells may have HTML.</p> <p>Currently, my code looks like this (relevant hunks shown below):</p> <pre><code>const string ...
[ { "answer_id": 179819, "author": "Santiago Palladino", "author_id": 12791, "author_profile": "https://Stackoverflow.com/users/12791", "pm_score": 2, "selected": false, "text": "<p>You can use a regex with balancing groups and backreferences, but I strongly recommend that you use a <a hre...
2008/10/07
[ "https://Stackoverflow.com/questions/179779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13700/" ]
I am writing code for a search results page that needs to highlight search terms. The terms happen to occur within table cells (the app is iterating through GridView Row Cells), and these table cells may have HTML. Currently, my code looks like this (relevant hunks shown below): ``` const string highlightPattern = @"...
This regex should do the job : `(?<!<[^>]*)(regex you want to check: Fred|span)` It checks that it is impossible to match the regex `<[^>]*` going backward starting from a matching string. Modified code below: ``` const string notInsideBracketsRegex = @"(?<!<[^>]*)"; const string highlightPattern = @"<span class=""Hi...
179,799
<p>Yesterday I tried to get started with Java RMI. I found this sun tutorial (<a href="http://java.sun.com/docs/books/tutorial/rmi/index.html" rel="nofollow noreferrer">http://java.sun.com/docs/books/tutorial/rmi/index.html</a>) and started with the server implemantation. But everytime I start the pogram (the rmiregist...
[ { "answer_id": 180176, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 3, "selected": false, "text": "<p>Grant of all permissions to all code is a really bad. Any RMI client could do what it wanted as logged in u...
2008/10/07
[ "https://Stackoverflow.com/questions/179799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25913/" ]
Yesterday I tried to get started with Java RMI. I found this sun tutorial (<http://java.sun.com/docs/books/tutorial/rmi/index.html>) and started with the server implemantation. But everytime I start the pogram (the rmiregistry is running) I get an AccessControlException with the following StackTrace: ``` LoginImpl exc...
Grant of all permissions to all code is a really bad. Any RMI client could do what it wanted as logged in user. In general try to restrict permissions as much as reasonable, particularly when you don't know where the code has come from. Back to the question... ``` -Djava.rmi.server.codebase=file://C:/ProjX/server/ser...
179,826
<p>Does anyone know of crossbrowser equivalent of explicitOriginalTarget event parameter? This parameter is Mozilla specific and it gives me the element that caused the blur. Let's say i have a text input and a link on my page. Text input has the focus. If I click on the link, text input's blur event gives me the link ...
[ { "answer_id": 179991, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 1, "selected": false, "text": "<p>Looks like it is more designed for extension writers than for Web design...</p>\n\n<p>I would watch the blur/focus event...
2008/10/07
[ "https://Stackoverflow.com/questions/179826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25768/" ]
Does anyone know of crossbrowser equivalent of explicitOriginalTarget event parameter? This parameter is Mozilla specific and it gives me the element that caused the blur. Let's say i have a text input and a link on my page. Text input has the focus. If I click on the link, text input's blur event gives me the link ele...
There is no equivalent to explicitOriginalTarget in any of the other than Gecko-based browsers. In Gecko this is an internal property and it is not supposed to be used by an application developer (maybe by XBL binding writers).
179,839
<p>Basically, I'm trying to selectively copy a table from one database to another. I have two different [Oracle] databases (e.g., running on different hosts) with the same schema. I'm interested in a efficient way to load Table A in DB1 with the result of running a select on Table A in DB2. I'm using JDBC, if that's re...
[ { "answer_id": 179870, "author": "CaptainPicard", "author_id": 15203, "author_profile": "https://Stackoverflow.com/users/15203", "pm_score": 4, "selected": true, "text": "<p>Use a database link, and use create table as select.</p>\n\n<pre><code>create database link other_db connect to re...
2008/10/07
[ "https://Stackoverflow.com/questions/179839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25915/" ]
Basically, I'm trying to selectively copy a table from one database to another. I have two different [Oracle] databases (e.g., running on different hosts) with the same schema. I'm interested in a efficient way to load Table A in DB1 with the result of running a select on Table A in DB2. I'm using JDBC, if that's relev...
Use a database link, and use create table as select. ``` create database link other_db connect to remote_user identified by remote_passwd using remote_tnsname; create table a as select * from a@other_db; ```
179,927
<p>In visual studio, I have an asp.net 3.5 project that is using MS Enterprise Library 4.0 application blocks. </p> <p>When I have my web config file open, my Error list fills up with 99 messages with things like </p> <pre><code>Could not find schema information for the element 'dataConfiguration'. Could not find s...
[ { "answer_id": 179945, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 1, "selected": false, "text": "<p>Have you tried copying the schema file to the XML Schema Caching folder for VS? You can find the location of that ...
2008/10/07
[ "https://Stackoverflow.com/questions/179927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16391/" ]
In visual studio, I have an asp.net 3.5 project that is using MS Enterprise Library 4.0 application blocks. When I have my web config file open, my Error list fills up with 99 messages with things like ``` Could not find schema information for the element 'dataConfiguration'. Could not find schema information for...
I configured the `app.config` with the tool for EntLib configuration and set up my `LoggingConfiguration` block. Then I copied this into the `DotNetConfig.xsd`. Of course, it does not cover all attributes, only the ones I added but it does not display those annoying info messages anymore. ``` <xs:element name="logging...
179,934
<p>This is my first time attempting to call an ASP.NET page method from jQuery. I am getting a status 500 error with the responseText message that the web method cannot be found. Here is my jQuery $.ajax call:</p> <pre><code>function callCancelPlan(activePlanId, ntLogin) { var paramList = '{"activePlanId":"' + act...
[ { "answer_id": 179941, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 8, "selected": true, "text": "<p>Your web method needs to be public and static.</p>\n" }, { "answer_id": 5898609, "author": "Cory House", ...
2008/10/07
[ "https://Stackoverflow.com/questions/179934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1284/" ]
This is my first time attempting to call an ASP.NET page method from jQuery. I am getting a status 500 error with the responseText message that the web method cannot be found. Here is my jQuery $.ajax call: ``` function callCancelPlan(activePlanId, ntLogin) { var paramList = '{"activePlanId":"' + activePlanId + '"...
Your web method needs to be public and static.
179,938
<p>i'm want to have a repeater generate a bunch of checkboxes, e.g.:</p> <pre><code>&lt;tr&gt;&lt;td&gt;&lt;input type="checkbox" name="t" value="11cbf4deb87" /&gt; &lt;input type="checkbox" name="a" value="33cbf4deb87" /&gt;stackoverflow.com&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="checkbox" name="t"...
[ { "answer_id": 179974, "author": "Dana", "author_id": 7856, "author_profile": "https://Stackoverflow.com/users/7856", "pm_score": 2, "selected": false, "text": "<p>You might find it easier to use a CheckBoxList control.</p>\n\n<p>In the simple case, you would set the DataTextVield and th...
2008/10/07
[ "https://Stackoverflow.com/questions/179938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
i'm want to have a repeater generate a bunch of checkboxes, e.g.: ``` <tr><td><input type="checkbox" name="t" value="11cbf4deb87" /> <input type="checkbox" name="a" value="33cbf4deb87" />stackoverflow.com</td></tr> <tr><td><input type="checkbox" name="t" value="11cbf4deb88" /> <input type="checkbox" name="a" value="33...
Use the server control instead of making an input control runat=server ``` <asp:CheckBox id="whatever" runat="Server" /> ``` When you set the value in your ItemDataBound, you use FindControl ``` CheckBox checkBox = (CheckBox)e.Item.FindControl("whatever"); checkBox.Checked = true; ``` When you get the items, you...
179,940
<p>We are developing a C# application for a web-service client. This will run on Windows XP PC's.</p> <p>One of the fields returned by the web service is a DateTime field. The server returns a field in GMT format i.e. with a "Z" at the end.</p> <p>However, we found that .NET seems to do some kind of implicit conversi...
[ { "answer_id": 179966, "author": "coder1", "author_id": 3018, "author_profile": "https://Stackoverflow.com/users/3018", "pm_score": 6, "selected": false, "text": "<pre><code>TimeZone.CurrentTimeZone.ToLocalTime(date);\n</code></pre>\n" }, { "answer_id": 180105, "author": "rbr...
2008/10/07
[ "https://Stackoverflow.com/questions/179940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9922/" ]
We are developing a C# application for a web-service client. This will run on Windows XP PC's. One of the fields returned by the web service is a DateTime field. The server returns a field in GMT format i.e. with a "Z" at the end. However, we found that .NET seems to do some kind of implicit conversion and the time w...
For strings such as `2012-09-19 01:27:30.000`, `DateTime.Parse` cannot tell what time zone the date and time are from. `DateTime` has a *Kind* property, which can have one of three time zone options: * Unspecified * Local * Utc **NOTE** *If you are wishing to represent a date/time other than UTC or your local time z...
179,955
<p>Many Java Apps don't use anti-aliased fonts by default, despite the capability of Swing to provide them. How can you coerce an arbitrary java application to use AA fonts? (both for applications I'm running, and applications I'm developing)</p>
[ { "answer_id": 179971, "author": "rcreswick", "author_id": 3446, "author_profile": "https://Stackoverflow.com/users/3446", "pm_score": 7, "selected": true, "text": "<p>If you have access to the source, you can do this in the main method:</p>\n\n<pre><code> // enable anti-aliased text:\n...
2008/10/07
[ "https://Stackoverflow.com/questions/179955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3446/" ]
Many Java Apps don't use anti-aliased fonts by default, despite the capability of Swing to provide them. How can you coerce an arbitrary java application to use AA fonts? (both for applications I'm running, and applications I'm developing)
If you have access to the source, you can do this in the main method: ``` // enable anti-aliased text: System.setProperty("awt.useSystemAAFontSettings","on"); ``` or, (and if you do not have access to the source, or if this is easier) you can simply pass the system properties above into the jvm by adding these o...
179,985
<p>We have a database library in C# that we can use like this:</p> <pre><code>DatabaseConnection conn = DatabaseConnection.FromConnectionString("..."); </code></pre> <p>This library hides many of the differences between different database engines, like SQL function names, parameter names and specifications, etc.</p> ...
[ { "answer_id": 180009, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 4, "selected": true, "text": "<p>This is possible in Python, but is probably not the best way to do it. The class factory pattern is essentially a wo...
2008/10/07
[ "https://Stackoverflow.com/questions/179985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
We have a database library in C# that we can use like this: ``` DatabaseConnection conn = DatabaseConnection.FromConnectionString("..."); ``` This library hides many of the differences between different database engines, like SQL function names, parameter names and specifications, etc. Internally, the `DatabaseConn...
This is possible in Python, but is probably not the best way to do it. The class factory pattern is essentially a workaround for languages that don't have first class classes. Since Python does have first class classes, you can store a class in a variable, and use that class directly to create instances. To change what...
179,987
<p>I am in a situation where I must update an existing database structure from varchar to nvarchar using a script. Since this script is run everytime a configuration application is run, I would rather determine if a column has already been changed to nvarchar and not perform an alter on the table. The databases which...
[ { "answer_id": 180022, "author": "Peter", "author_id": 5189, "author_profile": "https://Stackoverflow.com/users/5189", "pm_score": 3, "selected": true, "text": "<p>The following query should get you what you need:</p>\n\n<pre><code>IF EXISTS \n (SELECT *\n FROM sysobjects syo\n JOIN...
2008/10/07
[ "https://Stackoverflow.com/questions/179987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4441/" ]
I am in a situation where I must update an existing database structure from varchar to nvarchar using a script. Since this script is run everytime a configuration application is run, I would rather determine if a column has already been changed to nvarchar and not perform an alter on the table. The databases which I mu...
The following query should get you what you need: ``` IF EXISTS (SELECT * FROM sysobjects syo JOIN syscolumns syc ON syc.id = syo.id JOIN systypes syt ON syt.xtype = syc.xtype WHERE syt.name = 'nvarchar' AND syo.name = 'MY TABLE NAME' AND syc.name = 'MY COLUMN NAME') BEGIN A...
179,988
<p>Wanted to see peoples thoughts on best way to organize directory and project structure on a project / solution for a winforms C# app. </p> <p>Most people agree its best to seperate view, business logic, data objects, interfaces but wanted to see how different people tackle this. In addition, isolate third party d...
[ { "answer_id": 180029, "author": "Bill", "author_id": 14547, "author_profile": "https://Stackoverflow.com/users/14547", "pm_score": 0, "selected": false, "text": "<p>We usually keep SourceSafe projects, project names, namespaces and directory structures in sync. </p>\n\n<p>For example, g...
2008/10/07
[ "https://Stackoverflow.com/questions/179988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
Wanted to see peoples thoughts on best way to organize directory and project structure on a project / solution for a winforms C# app. Most people agree its best to seperate view, business logic, data objects, interfaces but wanted to see how different people tackle this. In addition, isolate third party dependencies ...
For me it depends on the model I'm following. If I'm using MVC it would be ``` Project -Models -Controllers -Views ``` Or for MVP it would be ``` Project -Models -Presenters -Views ``` Under the views I seperate them into namespaces relevant to the controllers, i.e. if I have a controller to handle inventory tran...
180,003
<p>I would like a code sample for a function that takes a tDateTime and an integer as input and sets the system time using setlocaltime after advancing that tDateTime by (int) months. The time should stay the same.</p> <p>pseudo code example</p> <pre><code>SetNewTime(NOW,2); </code></pre> <p>The issues I'm running i...
[ { "answer_id": 180065, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 4, "selected": true, "text": "<p>Below is a complete command-line program that works for me. Tested in Delphi 5 and 2007. Why do you say <a href=\"htt...
2008/10/07
[ "https://Stackoverflow.com/questions/180003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172/" ]
I would like a code sample for a function that takes a tDateTime and an integer as input and sets the system time using setlocaltime after advancing that tDateTime by (int) months. The time should stay the same. pseudo code example ``` SetNewTime(NOW,2); ``` The issues I'm running into are rather frustrating. I can...
Below is a complete command-line program that works for me. Tested in Delphi 5 and 2007. Why do you say [IncMonth](http://www.delphibasics.co.uk/RTL.asp?Name=IncMonth) does not work for TDateTime? ``` program OneMonth; {$APPTYPE CONSOLE} uses SysUtils, Windows, Messages; procedure SetLocalSystemTime(settotime...
180,005
<p>This Linq to SQL query ...</p> <pre><code> Return (From t In Db.Concessions Where t.Country = "ga" Select t.ConcessionID, t.Title, t.Country) </code></pre> <p>... is generating this SQL:</p> <pre><code>SELECT [t0].[ConcessionID], [t0].[Title], [t0].[Country] FROM [dbo].[Concessions] AS [t0] WHERE [t0].[Country...
[ { "answer_id": 180035, "author": "Jeff Mc", "author_id": 25521, "author_profile": "https://Stackoverflow.com/users/25521", "pm_score": -1, "selected": false, "text": "<p>the select should be</p>\n\n<pre><code>Select New With {t.ConcessionID, t.Title, t.Country}\n</code></pre>\n\n<p>rathe...
2008/10/07
[ "https://Stackoverflow.com/questions/180005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
This Linq to SQL query ... ``` Return (From t In Db.Concessions Where t.Country = "ga" Select t.ConcessionID, t.Title, t.Country) ``` ... is generating this SQL: ``` SELECT [t0].[ConcessionID], [t0].[Title], [t0].[Country] FROM [dbo].[Concessions] AS [t0] WHERE [t0].[Country] = ga ``` ... when what I want is ...
Answer ------ The Country field was a char(2); I changed it to nvarchar(50), and that fixed the problem. Is this a bug in Linq to SQL?
180,030
<p>In windows XP "FileInfo.LastWriteTime" will return the date a picture is taken - regardless of how many times the file is moved around in the filesystem.</p> <p>In Vista it instead returns the date that the picture is copied from the camera.</p> <p>How can I find out when a picture is taken in Vista? In windows ex...
[ { "answer_id": 180055, "author": "DaveK", "author_id": 4244, "author_profile": "https://Stackoverflow.com/users/4244", "pm_score": 3, "selected": false, "text": "<p>With WPF and C# you can get the Date Taken property using the BitmapMetadata class:</p>\n\n<p><a href=\"http://msdn.microso...
2008/10/07
[ "https://Stackoverflow.com/questions/180030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25930/" ]
In windows XP "FileInfo.LastWriteTime" will return the date a picture is taken - regardless of how many times the file is moved around in the filesystem. In Vista it instead returns the date that the picture is copied from the camera. How can I find out when a picture is taken in Vista? In windows explorer this field...
Here's as fast and clean as you can get it. By using FileStream, you can tell GDI+ not to load the whole image for verification. It runs over 10 × as fast on my machine. ``` //we init this once so that if the function is repeatedly called //it isn't stressing the garbage man private static Regex r = new Regex(":"); /...
180,032
<p>Right now, I have a SQL Query like this one:</p> <pre><code>SELECT X, Y FROM POINTS </code></pre> <p>It returns results like so:</p> <pre><code>X Y ---------- 12 3 15 2 18 12 20 29 </code></pre> <p>I'd like to return results all in one row, like this (suitable for using in an HTML &lt;AREA&gt; tag):</...
[ { "answer_id": 180053, "author": "Peter", "author_id": 5189, "author_profile": "https://Stackoverflow.com/users/5189", "pm_score": 1, "selected": false, "text": "<pre><code>DECLARE @s VarChar(8000)\nSET @s = ''\n\nSELECT @s = @s + ',' + CAST(X AS VarChar) + ',' + CAST(Y AS VarChar) \nFRO...
2008/10/07
[ "https://Stackoverflow.com/questions/180032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8409/" ]
Right now, I have a SQL Query like this one: ``` SELECT X, Y FROM POINTS ``` It returns results like so: ``` X Y ---------- 12 3 15 2 18 12 20 29 ``` I'd like to return results all in one row, like this (suitable for using in an HTML <AREA> tag): ``` XYLIST ---------- 12,3,15,2,18,12,20,29 ``` Is th...
``` DECLARE @XYList varchar(MAX) SET @XYList = '' SELECT @XYList = @XYList + CONVERT(varchar, X) + ',' + CONVERT(varchar, Y) + ',' FROM POINTS -- Remove last comma SELECT LEFT(@XYList, LEN(@XYList) - 1) ```
180,095
<p>I've written a simple multi-threaded game server in python that creates a new thread for each client connection. I'm finding that every now and then, the server will crash because of a broken-pipe/SIGPIPE error. I'm pretty sure it is happening when the program tries to send a response back to a client that is no l...
[ { "answer_id": 180152, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 6, "selected": true, "text": "<p>Read up on the try: statement.</p>\n\n<pre><code>try:\n # do something\nexcept socket.error, e:\n # A socket error\...
2008/10/07
[ "https://Stackoverflow.com/questions/180095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24208/" ]
I've written a simple multi-threaded game server in python that creates a new thread for each client connection. I'm finding that every now and then, the server will crash because of a broken-pipe/SIGPIPE error. I'm pretty sure it is happening when the program tries to send a response back to a client that is no longer...
Read up on the try: statement. ``` try: # do something except socket.error, e: # A socket error except IOError, e: if e.errno == errno.EPIPE: # EPIPE error else: # Other error ```
180,097
<p>I need to make some reflective method calls in Java. Those calls will include methods that have arguments that are primitive types (int, double, etc.). The way to specify such types when looking up the method reflectively is int.class, double.class, etc.</p> <p>The challenge is that I am accepting input from an out...
[ { "answer_id": 180139, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 5, "selected": false, "text": "<p>The <code>Class</code> instances for the primitive types are obtainable as you said using e.g. <code>int.class</co...
2008/10/07
[ "https://Stackoverflow.com/questions/180097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3005/" ]
I need to make some reflective method calls in Java. Those calls will include methods that have arguments that are primitive types (int, double, etc.). The way to specify such types when looking up the method reflectively is int.class, double.class, etc. The challenge is that I am accepting input from an outside sourc...
The Spring framework contains a utility class [ClassUtils](http://static.springframework.org/spring/docs/1.1.5/api/org/springframework/util/ClassUtils.html) which contains the static method forName. This method can be used for the exact purpose you described. In case you don’t like to have a dependency on Spring: the ...
180,103
<p>I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is correct way (if any) to set the title of the document?</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { /...
[ { "answer_id": 180118, "author": "cllpse", "author_id": 20946, "author_profile": "https://Stackoverflow.com/users/20946", "pm_score": 5, "selected": false, "text": "<p>Like this:</p>\n\n<pre><code>$(document).ready(function ()\n{\n document.title = \"Hello World!\";\n});\n</code></pre...
2008/10/07
[ "https://Stackoverflow.com/questions/180103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18811/" ]
I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is correct way (if any) to set the title of the document? ``` <script type="text/javascript"> $(document).ready(function() { // ??? }); </script>...
The following should work but it wouldn't be SEO compatible. It's best to put the title in the title tag. ``` <script type="text/javascript"> $(document).ready(function() { document.title = 'blah'; }); </script> ```
180,119
<p>I recently started working on a small game for my own amusement, using Microsoft XNA and C#. My question is in regards to designing a game object and the objects that inherit it. I'm going to define a game object as something that can be rendered on screen. So for this, I decided to make a base class which all other...
[ { "answer_id": 180146, "author": "Ryan", "author_id": 17917, "author_profile": "https://Stackoverflow.com/users/17917", "pm_score": 2, "selected": false, "text": "<p>This design doesn't separate the UI parts of an object and the behavior parts of an object, the \"model\" and \"view\" so ...
2008/10/07
[ "https://Stackoverflow.com/questions/180119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19649/" ]
I recently started working on a small game for my own amusement, using Microsoft XNA and C#. My question is in regards to designing a game object and the objects that inherit it. I'm going to define a game object as something that can be rendered on screen. So for this, I decided to make a base class which all other ob...
Personally I find the sheer number of constructors you have a little offputting, but that's your choice, nothing fundamentally wrong with it :) With regards to the general strategy of deriving game objects from a common base, that's a pretty common way to do things. Standard, even. I've tended to start using something...
180,158
<ol> <li>How do I get a method's execution time? </li> <li>Is there a <code>Timer</code> utility class for things like timing how long a task takes, etc? </li> </ol> <p>Most of the searches on Google return results for timers that schedule threads and tasks, which is not what I want.</p>
[ { "answer_id": 180171, "author": "skaffman", "author_id": 21234, "author_profile": "https://Stackoverflow.com/users/21234", "pm_score": 5, "selected": false, "text": "<p>This probably isn't what you wanted me to say, but this is a good use of AOP. Whip an proxy interceptor around your me...
2008/10/07
[ "https://Stackoverflow.com/questions/180158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13140/" ]
1. How do I get a method's execution time? 2. Is there a `Timer` utility class for things like timing how long a task takes, etc? Most of the searches on Google return results for timers that schedule threads and tasks, which is not what I want.
There is always the old-fashioned way: ``` long startTime = System.nanoTime(); methodToTime(); long endTime = System.nanoTime(); long duration = (endTime - startTime); //divide by 1000000 to get milliseconds. ```
180,172
<p>Is there any good reason that an empty set of round brackets (parentheses) isn't valid for calling the default constructor in C++?</p> <pre><code>MyObject object; // ok - default ctor MyObject object(blah); // ok MyObject object(); // error </code></pre> <p>I seem to type "()" automatically everytime. Is the...
[ { "answer_id": 180185, "author": "Nemanja Trifunovic", "author_id": 8899, "author_profile": "https://Stackoverflow.com/users/8899", "pm_score": 6, "selected": false, "text": "<p>The same syntax is used for function declaration - e.g. the function <code>object</code>, taking no parameters...
2008/10/07
[ "https://Stackoverflow.com/questions/180172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10897/" ]
Is there any good reason that an empty set of round brackets (parentheses) isn't valid for calling the default constructor in C++? ``` MyObject object; // ok - default ctor MyObject object(blah); // ok MyObject object(); // error ``` I seem to type "()" automatically everytime. Is there a good reason this isn'...
**Most vexing parse** This is related to what is known as "C++'s most vexing parse". Basically, anything that can be interpreted by the compiler as a function declaration will be interpreted as a function declaration. Another instance of the same problem: ``` std::ifstream ifs("file.txt"); std::vector<T> v(std::istr...
180,211
<p>To make click-able divs, I do:</p> <pre><code>&lt;div class="clickable" url="http://google.com"&gt; blah blah &lt;/div&gt; </code></pre> <p>and then </p> <pre><code>$("div.clickable").click( function() { window.location = $(this).attr("url"); }); </code></pre> <p>I don't know if this is the best way, but...
[ { "answer_id": 180246, "author": "Sergey Ilinsky", "author_id": 23815, "author_profile": "https://Stackoverflow.com/users/23815", "pm_score": 3, "selected": false, "text": "<p><code>\n$(\"div.clickable\").click(\nfunction(event)\n{\n window.location = $(this).attr(\"url\");\n event...
2008/10/07
[ "https://Stackoverflow.com/questions/180211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2721/" ]
To make click-able divs, I do: ``` <div class="clickable" url="http://google.com"> blah blah </div> ``` and then ``` $("div.clickable").click( function() { window.location = $(this).attr("url"); }); ``` I don't know if this is the best way, but it works perfectly with me, except for one issue: If the div...
If you return "false" from your function it'll stop the event bubbling, so only your first event handler will get triggered (ie. your anchor will not see the click). ``` $("div.clickable").click( function() { window.location = $(this).attr("url"); return false; }); ``` See [event.preventDefault() vs. return ...
180,242
<p>We are making a Ruby On Rails webapp where every customer gets their own database.<br> The database needs to be created after they fill out a form on our website.</p> <p>We have a template database that has all of the tables and columns that we need to copy. How can I do this in programatically from ruby on rails?...
[ { "answer_id": 180282, "author": "Tilendor", "author_id": 1470, "author_profile": "https://Stackoverflow.com/users/1470", "pm_score": 4, "selected": true, "text": "<p>From any controller, you can define the following method.</p>\n\n<pre><code> def copy_template_database\n template...
2008/10/07
[ "https://Stackoverflow.com/questions/180242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1470/" ]
We are making a Ruby On Rails webapp where every customer gets their own database. The database needs to be created after they fill out a form on our website. We have a template database that has all of the tables and columns that we need to copy. How can I do this in programatically from ruby on rails?
From any controller, you can define the following method. ``` def copy_template_database template_name = "customerdb1" # Database to copy from new_name = "temp" #database to create & copy to #connect to template database to copy. Note that this will override any previous #connections...
180,245
<p>I have this CheckBoxList on a page:</p> <pre><code>&lt;asp:checkboxlist runat="server" id="Locations" datasourceid="LocationsDatasource" datatextfield="CountryName" datavaluefield="CountryCode" /&gt; </code></pre> <p>I'd like to loop through the checkbox elements on the client using Javascript and grab the valu...
[ { "answer_id": 180253, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 3, "selected": true, "text": "<p>Stored in ViewState, you cannot access them on the client without <a href=\"http://www.daveparslow.com/2007/08/assig...
2008/10/07
[ "https://Stackoverflow.com/questions/180245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I have this CheckBoxList on a page: ``` <asp:checkboxlist runat="server" id="Locations" datasourceid="LocationsDatasource" datatextfield="CountryName" datavaluefield="CountryCode" /> ``` I'd like to loop through the checkbox elements on the client using Javascript and grab the value of each checked checkbox, but ...
Stored in ViewState, you cannot access them on the client without [**some hacking**](http://www.daveparslow.com/2007/08/assigning-value-to-aspnet-checkbox.html).
180,266
<p>How do you think, is it a good idea to have such an enum:</p> <pre><code>enum AvailableSpace { Percent10, Percent20, SqF500, SqF600 } </code></pre> <p>The question is about the semantics of the values names, i.e. both percentage and square feet. I really believe that it's not a good idea, but I could n...
[ { "answer_id": 180284, "author": "Chris Wenham", "author_id": 5548, "author_profile": "https://Stackoverflow.com/users/5548", "pm_score": 3, "selected": false, "text": "<p>If at all possible, I'd rather break your example into two values, where your enum is \"Percent\" and \"SquareFeet\"...
2008/10/07
[ "https://Stackoverflow.com/questions/180266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8220/" ]
How do you think, is it a good idea to have such an enum: ``` enum AvailableSpace { Percent10, Percent20, SqF500, SqF600 } ``` The question is about the semantics of the values names, i.e. both percentage and square feet. I really believe that it's not a good idea, but I could not find and guidelines, et...
**The answer**: No, it is not a good idea to use enums for representing values. Especially values in two semantically distinct scales. You should not use enums for values. **The reason**: What's the relation between the enum values from the two scales, like Percent10 and SqF600? How do you expand the list of values yo...
180,272
<p>Is it even possible?</p> <p>Basically, there's a remote repository from which I pull using just:</p> <pre><code>git pull </code></pre> <p>Now, I'd like to preview what this pull would change (a diff) without touching anything on my side. The reason is that thing I'm pulling might not be "good" and I want someone ...
[ { "answer_id": 180329, "author": "Brian Gianforcaro", "author_id": 3415, "author_profile": "https://Stackoverflow.com/users/3415", "pm_score": 6, "selected": false, "text": "<p>I think <strong>git fetch</strong> is what your looking for. </p>\n\n<p>It will pull the changes and objects wi...
2008/10/07
[ "https://Stackoverflow.com/questions/180272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14690/" ]
Is it even possible? Basically, there's a remote repository from which I pull using just: ``` git pull ``` Now, I'd like to preview what this pull would change (a diff) without touching anything on my side. The reason is that thing I'm pulling might not be "good" and I want someone else to fix it before making my r...
After doing a `git fetch`, do a `git log HEAD..origin/master` to show the log entries between your last common commit and the origin's master branch. To show the diffs, use either `git log -p HEAD..origin/master` to show each patch, or `git diff HEAD...origin/master` (three dots not two) to show a single diff. There n...
180,327
<p>I need to solve a few mathematical equations in my application. Here's a typical example of such an equation:</p> <pre><code>a + b * c - d / e = a </code></pre> <p>Additional rules:</p> <ul> <li>b % 10 = 0</li> <li>b >= 0</li> <li>b &lt;= 100</li> <li>Each number must be integer</li> <li>...</li> </ul> <p>I woul...
[ { "answer_id": 180360, "author": "Simon", "author_id": 24039, "author_profile": "https://Stackoverflow.com/users/24039", "pm_score": 0, "selected": false, "text": "<p>Pretty sure <a href=\"http://www.nr.com/\" rel=\"nofollow noreferrer\">Numerical Recipes</a> will have something</p>\n" ...
2008/10/07
[ "https://Stackoverflow.com/questions/180327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15288/" ]
I need to solve a few mathematical equations in my application. Here's a typical example of such an equation: ``` a + b * c - d / e = a ``` Additional rules: * b % 10 = 0 * b >= 0 * b <= 100 * Each number must be integer * ... I would like to get the possible solution sets for a, b, c, d and e. Are there **any li...
Solving [linear systems](http://en.wikipedia.org/wiki/Linear_systems) can *generally* be solved using linear programming. I'd recommend taking a look at [Boost uBLAS](http://www.boost.org/doc/libs/1_36_0/libs/numeric/ublas/doc/index.htm) for starters - it has a simple triangular solver. Then you might checkout librarie...
180,328
<p>So lets say I have a dataset based on:</p> <pre><code>SELECT TopicLink.*, Topic.Name AS FromTopicName, Topic_1.Name AS ToTopicName FROM TopicLink INNER JOIN Topic ON TopicLink.FromTopicId = Topic.TopicId INNER JOIN Topic AS Topic_1 ON TopicLink.ToTopicId = Top...
[ { "answer_id": 180344, "author": "Vijesh VP", "author_id": 22016, "author_profile": "https://Stackoverflow.com/users/22016", "pm_score": 2, "selected": true, "text": "<p>I think you can achive this by providing your own update command for the ADO.net DataAdaptor. Check out the sample pro...
2008/10/07
[ "https://Stackoverflow.com/questions/180328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8678/" ]
So lets say I have a dataset based on: ``` SELECT TopicLink.*, Topic.Name AS FromTopicName, Topic_1.Name AS ToTopicName FROM TopicLink INNER JOIN Topic ON TopicLink.FromTopicId = Topic.TopicId INNER JOIN Topic AS Topic_1 ON TopicLink.ToTopicId = Topic_1.TopicId ...
I think you can achive this by providing your own update command for the ADO.net DataAdaptor. Check out the sample provided [here](http://www.ondotnet.com/pub/a/dotnet/excerpt/progvisbasic_ch08-2/index.html?page=4).
180,330
<p>I've got a save dialog box which pops up when i press a button. However i dont want to save a file at that point, i want to take the name and place it in the text box next to the button, for the name to be used later. </p> <p>Can anybody tell me how to obtain the file path from the save dialog box to use it later?<...
[ { "answer_id": 180332, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 7, "selected": true, "text": "<p>Here is a sample code I just wrote very fast... instead of Console.Write you can simply store the path in a v...
2008/10/07
[ "https://Stackoverflow.com/questions/180330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14441/" ]
I've got a save dialog box which pops up when i press a button. However i dont want to save a file at that point, i want to take the name and place it in the text box next to the button, for the name to be used later. Can anybody tell me how to obtain the file path from the save dialog box to use it later?
Here is a sample code I just wrote very fast... instead of Console.Write you can simply store the path in a variable and use it later. ``` SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments); saveFileDialog1.Filter = "Your ...
180,349
<p>In our program, each customer gets their own database. We e-mail them a link that connects them to their database. The link contains a GUID that lets the program know which database to connect to.</p> <p>How do I dynamically and programatically connect ActiveRecord to the right db?</p>
[ { "answer_id": 180355, "author": "Tilendor", "author_id": 1470, "author_profile": "https://Stackoverflow.com/users/1470", "pm_score": 4, "selected": false, "text": "<p>you can change the connection to ActiveRecord at any time by calling ActiveRecord::Base.establish_connection(...)</p>\n\...
2008/10/07
[ "https://Stackoverflow.com/questions/180349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1470/" ]
In our program, each customer gets their own database. We e-mail them a link that connects them to their database. The link contains a GUID that lets the program know which database to connect to. How do I dynamically and programatically connect ActiveRecord to the right db?
You can also do this easily without hardcoding anything and run migrations automatically: ``` customer = CustomerModel.find(id) spec = CustomerModel.configurations[RAILS_ENV] new_spec = spec.clone new_spec["database"] = customer.database_name ActiveRecord::Base.establish_connection(new_spec) ActiveRecord::Migrator.mig...
180,366
<p>I have a Page that has a single instance of a UserControl that itself has a single UpdatePanel. Inside the UpdatePanel are several Button controls. The Click event for these controls are wired up in the code-behind, in the Init event of the UserControl.</p> <p>I get the Click event for the first button I push, ev...
[ { "answer_id": 180641, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 3, "selected": true, "text": "<p>It seems that adding UseSubmitBehavior=\"false\" to the button definitions has solved my problem. Still don't know why t...
2008/10/07
[ "https://Stackoverflow.com/questions/180366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35/" ]
I have a Page that has a single instance of a UserControl that itself has a single UpdatePanel. Inside the UpdatePanel are several Button controls. The Click event for these controls are wired up in the code-behind, in the Init event of the UserControl. I get the Click event for the first button I push, every time, no...
It seems that adding UseSubmitBehavior="false" to the button definitions has solved my problem. Still don't know why that first button click worked at all.
180,370
<p>I am aware of the <a href="http://msdn.microsoft.com/en-us/library/system.timezone(VS.80).aspx" rel="noreferrer">System.TimeZone</a> class as well as the many uses of the <a href="http://msdn.microsoft.com/en-us/library/system.datetime.tostring(VS.80).aspx" rel="noreferrer">DateTime.ToString()</a> method. What I ha...
[ { "answer_id": 180559, "author": "Gerald", "author_id": 19404, "author_profile": "https://Stackoverflow.com/users/19404", "pm_score": 0, "selected": false, "text": "<p>It depends on the level of robustness that you need.</p>\n\n<p>You'll probably need some kind of hack either way. An eas...
2008/10/07
[ "https://Stackoverflow.com/questions/180370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7290/" ]
I am aware of the [System.TimeZone](http://msdn.microsoft.com/en-us/library/system.timezone(VS.80).aspx) class as well as the many uses of the [DateTime.ToString()](http://msdn.microsoft.com/en-us/library/system.datetime.tostring(VS.80).aspx) method. What I haven't been able to find is a way to convert a DateTime to a ...
Here's my quick hack method I just made to work around this. ``` public static String TimeZoneName(DateTime dt) { String sName = TimeZone.CurrentTimeZone.IsDaylightSavingTime(dt) ? TimeZone.CurrentTimeZone.DaylightName : TimeZone.CurrentTimeZone.StandardName; String sNewName = ""; String...
180,371
<p>When extending classes, I find it very descriptive to use the <code>base</code> (<code>MyBase</code> in VB) keyword when accessing methods in the base-class. And the <code>this</code> (<code>Me</code> in VB) keyword when accessing functions in the class extending the base-class. That goes for a "flat" structure with...
[ { "answer_id": 180379, "author": "JohnC", "author_id": 25088, "author_profile": "https://Stackoverflow.com/users/25088", "pm_score": 3, "selected": true, "text": "<p>Have a look at StyleCop.</p>\n\n<p><a href=\"http://code.msdn.microsoft.com/sourceanalysis\" rel=\"nofollow noreferrer\">h...
2008/10/07
[ "https://Stackoverflow.com/questions/180371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20946/" ]
When extending classes, I find it very descriptive to use the `base` (`MyBase` in VB) keyword when accessing methods in the base-class. And the `this` (`Me` in VB) keyword when accessing functions in the class extending the base-class. That goes for a "flat" structure with no inheritance as well. I find it easier to r...
Have a look at StyleCop. <http://code.msdn.microsoft.com/sourceanalysis> There are some rules in there that should do what you want. You can configure it to show any style violations as warnings or errors.
180,401
<p>I've recently decided that I just have to finally learn C/C++, and there is one thing I do not really understand about pointers or more precisely, their definition.</p> <p>How about these examples:</p> <ol> <li><code>int* test;</code></li> <li><code>int *test;</code></li> <li><code>int * test;</code></li> <li><cod...
[ { "answer_id": 180409, "author": "Milan Babuškov", "author_id": 14690, "author_profile": "https://Stackoverflow.com/users/14690", "pm_score": 8, "selected": true, "text": "<p>4, 5, and 6 are the same thing, only <em>test</em> is a pointer. If you want two pointers, you should use:</p>\n\...
2008/10/07
[ "https://Stackoverflow.com/questions/180401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
I've recently decided that I just have to finally learn C/C++, and there is one thing I do not really understand about pointers or more precisely, their definition. How about these examples: 1. `int* test;` 2. `int *test;` 3. `int * test;` 4. `int* test,test2;` 5. `int *test,test2;` 6. `int * test,test2;` Now, to my...
4, 5, and 6 are the same thing, only *test* is a pointer. If you want two pointers, you should use: ``` int *test, *test2; ``` Or, even better (to make everything clear): ``` int* test; int* test2; ```
180,405
<p>I've got a User table with a bitmask that contains the user's roles. The linq query below returns all the users whose roles include 1, 4 or 16. </p> <pre><code>var users = from u in dc.Users where ((u.UserRolesBitmask &amp; 1) == 1) || ((u.UserRolesBitmask &amp; 4) == 4) ||...
[ { "answer_id": 180447, "author": "Dylan Beattie", "author_id": 5017, "author_profile": "https://Stackoverflow.com/users/5017", "pm_score": 2, "selected": false, "text": "<p>Assuming your UserRoles values are themselves bitmasks, would something like this work?</p>\n\n<pre><code>private L...
2008/10/07
[ "https://Stackoverflow.com/questions/180405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14072/" ]
I've got a User table with a bitmask that contains the user's roles. The linq query below returns all the users whose roles include 1, 4 or 16. ``` var users = from u in dc.Users where ((u.UserRolesBitmask & 1) == 1) || ((u.UserRolesBitmask & 4) == 4) || ((u.UserRolesBitmask ...
You can use the [PredicateBuilder](http://www.albahari.com/nutshell/predicatebuilder.aspx) class. PredicateBuilder has been released in the [LINQKit NuGet package](https://www.nuget.org/packages/LinqKit/) > > LINQKit is a free set of extensions for LINQ to SQL and Entity Framework power users. > > >
180,422
<p>I'm trying to determine which records to delete from a database when a user submits a form. The page has two CheckBoxList one representing the records before modification and one after.</p> <p>I can easily get the selected values that need to be deleted like this...</p> <pre><code>//get the items not selected that...
[ { "answer_id": 180524, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "<p>What is the error you are getting? Is it a type mismatch between SpecialNeedsTypeCd and oldSelectedItem.Value? Hav...
2008/10/07
[ "https://Stackoverflow.com/questions/180422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6161/" ]
I'm trying to determine which records to delete from a database when a user submits a form. The page has two CheckBoxList one representing the records before modification and one after. I can easily get the selected values that need to be deleted like this... ``` //get the items not selected that were selected before...
Local collections can be used in LINQ to SQL with the Contains() method. You can try changing the *join* clause into a *where* with Contains(): ``` var itemsToDelete = from specialNeed in db.SpecialNeeds where oldSelectedItems.Contains(specialNeed.SpecialNeedsTypeCd) && speci...
180,428
<pre><code>Option Explicit On Option Strict On Public Class Class1 Dim l As List(Of A) Public Sub New() l = New List(Of B) End Sub End Class Public Class A End Class Public Class B Inherits A End Class&lt;p&gt; </code></pre> <p>I've run into this problem.<br> I have a list declared of a G...
[ { "answer_id": 180442, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": true, "text": "<p>It's a matter of variance, which C# doesn't support for generics. See <a href=\"http://blogs.msdn.com/rmbyers/archive/...
2008/10/07
[ "https://Stackoverflow.com/questions/180428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24804/" ]
``` Option Explicit On Option Strict On Public Class Class1 Dim l As List(Of A) Public Sub New() l = New List(Of B) End Sub End Class Public Class A End Class Public Class B Inherits A End Class<p> ``` I've run into this problem. I have a list declared of a Generic Type 'A' I want ...
It's a matter of variance, which C# doesn't support for generics. See [Rick Byer's post on the subject](http://blogs.msdn.com/rmbyers/archive/2005/02/16/375079.aspx).
180,430
<p>I'm refactoring some PHP code and discovered that certain nested combinations of </p> <pre><code>if () : </code></pre> <p>and </p> <pre><code>if () { </code></pre> <p>generate syntax errors. Not that I would normally mix the two, but I like to do frequent syntax checks as I'm writing code and I kept getting a s...
[ { "answer_id": 180507, "author": "I GIVE CRAP ANSWERS", "author_id": 25083, "author_profile": "https://Stackoverflow.com/users/25083", "pm_score": 3, "selected": true, "text": "<p>This is a wild guess since I am not familiar with the grammar of PHP. But here goes:</p>\n\n<p>The problem i...
2008/10/07
[ "https://Stackoverflow.com/questions/180430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24190/" ]
I'm refactoring some PHP code and discovered that certain nested combinations of ``` if () : ``` and ``` if () { ``` generate syntax errors. Not that I would normally mix the two, but I like to do frequent syntax checks as I'm writing code and I kept getting a syntax error because of this. Example - generates ...
This is a wild guess since I am not familiar with the grammar of PHP. But here goes: The problem is the second `else`. The parser can't see if this `else` is belonging to the first or the second if (counting from the beginning). In your second example there is an `endif` making the second `if`-block be terminated so t...
180,451
<p>Using answers to <a href="https://stackoverflow.com/questions/57522/javascript-array-with-a-mix-of-literals-and-arrays">this question</a>, I have been able to populate a select box based on the selection of another select box. ( <a href="https://stackoverflow.com/questions/57522/javascript-array-with-a-mix-of-litera...
[ { "answer_id": 180593, "author": "Ionuț Staicu", "author_id": 23810, "author_profile": "https://Stackoverflow.com/users/23810", "pm_score": 1, "selected": false, "text": "<p>You should take a look <a href=\"http://www.texotela.co.uk/code/jquery/select/\" rel=\"nofollow noreferrer\">here<...
2008/10/07
[ "https://Stackoverflow.com/questions/180451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
Using answers to [this question](https://stackoverflow.com/questions/57522/javascript-array-with-a-mix-of-literals-and-arrays), I have been able to populate a select box based on the selection of another select box. ( [I posted my answer here](https://stackoverflow.com/questions/57522/javascript-array-with-a-mix-of-lit...
I prefer data structure like this: ``` var carMakers = [ { name: 'Honda', models: [ { name: 'Accord', features: ['2dr', '4dr'] }, { name: 'CRV', features: ['2dr', 'Hatchback'] }, { name: 'Pilot', features: ['base', 'superDuper'] } ]}, { name: 'Toyota', models: [ ...
180,452
<p>I have a c# form (let's call it MainForm) with a number of custom controls on it. I'd like to have the MainForm.OnClick() method fire anytime someone clicks on the form regardless of whether the click happened on the form or if the click was on one of the custom controls. I'm looking for behavior similar to the KeyP...
[ { "answer_id": 180476, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 0, "selected": false, "text": "<p>Catching a click on an open space on the form is easy, but to get a click that's actually on a control, you'll nee...
2008/10/07
[ "https://Stackoverflow.com/questions/180452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2191/" ]
I have a c# form (let's call it MainForm) with a number of custom controls on it. I'd like to have the MainForm.OnClick() method fire anytime someone clicks on the form regardless of whether the click happened on the form or if the click was on one of the custom controls. I'm looking for behavior similar to the KeyPrev...
In the form's ControlAdded event, add a MouseClick handler to the control, with the Address of the form's click event. I haven't tested this, but it might work. ``` Private Sub Example_ControlAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.ControlEventArgs) Handles Me.ControlAdded AddHandler e.Contr...
180,464
<p>I'm running PHP on Windows/IIS.</p> <p>My session variables don't seem to be preserved from page-to-page.</p> <p>This code&hellip;</p> <pre><code>//echos out the session variables in a nice format for inspection echo "&lt;p&gt;&lt;pre&gt;"; print_r($_SESSION); echo "&lt;/pre&gt;&lt;/p&gt;"; </code></pre> <p>&hel...
[ { "answer_id": 180486, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 1, "selected": false, "text": "<p>can you post a bit more of your session code? some basics:</p>\n\n<ul>\n<li>did you start your session? (<a href=\"http://ph...
2008/10/07
[ "https://Stackoverflow.com/questions/180464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
I'm running PHP on Windows/IIS. My session variables don't seem to be preserved from page-to-page. This code… ``` //echos out the session variables in a nice format for inspection echo "<p><pre>"; print_r($_SESSION); echo "</pre></p>"; ``` …outputs blank values, like this… ``` Array ( [s_firs...
Oops. I found that I was not using the correct syntax when assigning values: Does not work: ``` $_SESSION['$s_firstvar'] = 3; ``` Does work: ``` $_SESSION['s_firstvar'] = 3; ```
180,516
<p>I have roughly the following code. Could this be made nicer or more efficient? Perhaps using <code>std::remove_if</code>? Can you remove items from the map while traversing it? Can we avoid using the temporary map?</p> <pre><code>typedef std::map&lt;Action, What&gt; Actions; static Actions _actions; bool expired(c...
[ { "answer_id": 180532, "author": "Greg Rogers", "author_id": 5963, "author_profile": "https://Stackoverflow.com/users/5963", "pm_score": 1, "selected": false, "text": "<p>If the idea is to remove expired items, why not use <a href=\"http://www.cplusplus.com/reference/stl/map/erase.html\"...
2008/10/07
[ "https://Stackoverflow.com/questions/180516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3146/" ]
I have roughly the following code. Could this be made nicer or more efficient? Perhaps using `std::remove_if`? Can you remove items from the map while traversing it? Can we avoid using the temporary map? ``` typedef std::map<Action, What> Actions; static Actions _actions; bool expired(const Actions::value_type &actio...
You could use erase(), but I don't know how BOOST\_FOREACH will handle the invalidated iterator. The [documentation for map::erase](http://en.cppreference.com/w/cpp/container/map/erase) states that only the erased iterator will be invalidated, the others should be OK. Here's how I would restructure the inner loop: ```...
180,518
<p>I've just discovered that Oracle lets you do the following:</p> <pre><code>SELECT foo.a, (SELECT c FROM bar WHERE foo.a = bar.a) from foo </code></pre> <p>As long as only one row in bar matches any row in foo.</p> <p>The explain plan I get from PL/SQL developer is this:</p> <pre>...
[ { "answer_id": 180588, "author": "WW.", "author_id": 14663, "author_profile": "https://Stackoverflow.com/users/14663", "pm_score": 3, "selected": true, "text": "<p>The plan you have there does not provide much information at all. </p>\n\n<p>Use SQL*Plus and use dbms_xplan to get a more ...
2008/10/07
[ "https://Stackoverflow.com/questions/180518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15962/" ]
I've just discovered that Oracle lets you do the following: ``` SELECT foo.a, (SELECT c FROM bar WHERE foo.a = bar.a) from foo ``` As long as only one row in bar matches any row in foo. The explain plan I get from PL/SQL developer is this: ``` SELECT STATEMENT, GOAL = ALL_ROWS ...
The plan you have there does not provide much information at all. Use SQL\*Plus and use dbms\_xplan to get a more detailed plan. Look for a script called utlxpls.sql. This gives a bit more information:- ``` -------------------------------------------------------------------------- | Id | Operation | Name |...
180,563
<p>I'd like to bold the text for a tab page under certain conditions (not, necessarily, GotFocus). Is it true the only 'er easiest way to do this is by overriding the DrawItem event for the tab control?</p> <p><a href="http://www.vbforums.com/showthread.php?t=355093" rel="noreferrer">http://www.vbforums.com/showthrea...
[ { "answer_id": 180637, "author": "John Rudy", "author_id": 14048, "author_profile": "https://Stackoverflow.com/users/14048", "pm_score": 3, "selected": false, "text": "<p>When you set the Font property on a TabPage, you are setting the default font for all controls on that tab page. You ...
2008/10/07
[ "https://Stackoverflow.com/questions/180563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/81/" ]
I'd like to bold the text for a tab page under certain conditions (not, necessarily, GotFocus). Is it true the only 'er easiest way to do this is by overriding the DrawItem event for the tab control? <http://www.vbforums.com/showthread.php?t=355093> It seems like there should be an easier way. Like ... `tabControl...
When you set the Font property on a TabPage, you are setting the default font for all controls on that tab page. You are not setting it for the header, however. When you execute the following code: ``` tabControl.TabPages(index).Font = New Font(Me.Font, FontStyle.Bold) ``` Any controls on that page will now be bold...
180,572
<p>My situation is as follows:</p> <p>I have a normalized database, in which I hold geographic information about airports. The structure is:</p> <pre><code>airport --is in--&gt; city --is in--&gt; country --is in--&gt; continent </code></pre> <p>Now I want to let users administrate this data, without giving them dir...
[ { "answer_id": 184512, "author": "Ed Greaves", "author_id": 26262, "author_profile": "https://Stackoverflow.com/users/26262", "pm_score": 4, "selected": true, "text": "<p>Presumably you are writing a protocol layer that will understand your different message types. You will also need an...
2008/10/07
[ "https://Stackoverflow.com/questions/180572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25253/" ]
My situation is as follows: I have a normalized database, in which I hold geographic information about airports. The structure is: ``` airport --is in--> city --is in--> country --is in--> continent ``` Now I want to let users administrate this data, without giving them direct access to the database. We need to off...
Presumably you are writing a protocol layer that will understand your different message types. You will also need an application layer to parse the contents of the message. The different approaches you mention will shift the burden of parsing between these two layers. So for example: **Solution A**: The protocol layer...
180,601
<p>My style of coding includes the following idiom:</p> <pre><code>class Derived : public Base { public : typedef Base super; // note that it could be hidden in // protected/private section, instead // Etc. } ; </code></pre> <p>This enables me to use &quot;super&quot; as ...
[ { "answer_id": 180613, "author": "James Hopkin", "author_id": 11828, "author_profile": "https://Stackoverflow.com/users/11828", "pm_score": 2, "selected": false, "text": "<p>I've quite often seen it used, sometimes as super_t, when the base is a complex template type (<code>boost::iterat...
2008/10/07
[ "https://Stackoverflow.com/questions/180601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14089/" ]
My style of coding includes the following idiom: ``` class Derived : public Base { public : typedef Base super; // note that it could be hidden in // protected/private section, instead // Etc. } ; ``` This enables me to use "super" as an alias to Base, for example, in constr...
Bjarne Stroustrup mentions in *Design and Evolution of C++* that `super` as a keyword was considered by the ISO C++ Standards committee the first time C++ was standardized. Dag Bruck proposed this extension, calling the base class "inherited." The proposal mentioned the multiple inheritance issue, and would have flagg...
180,606
<p>I've got a list in a Python program that contains a series of numbers, which are themselves ASCII values. How do I convert this into a "regular" string that I can echo to the screen?</p>
[ { "answer_id": 180615, "author": "Thomas Wouters", "author_id": 17624, "author_profile": "https://Stackoverflow.com/users/17624", "pm_score": 8, "selected": true, "text": "<p>You are probably looking for 'chr()':</p>\n\n<pre><code>&gt;&gt;&gt; L = [104, 101, 108, 108, 111, 44, 32, 119, 1...
2008/10/07
[ "https://Stackoverflow.com/questions/180606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19074/" ]
I've got a list in a Python program that contains a series of numbers, which are themselves ASCII values. How do I convert this into a "regular" string that I can echo to the screen?
You are probably looking for 'chr()': ``` >>> L = [104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100] >>> ''.join(chr(i) for i in L) 'hello, world' ```
180,624
<p>I'm developing a solution which uses an ActiveX control (a commercial one which we bought and that I did not develop). I need to develop the proper installation pages to simulate what happens when a user who has never visited the site and does not have the add-on installed comes to the page.</p> <p>I've found the "...
[ { "answer_id": 180640, "author": "dummy", "author_id": 6297, "author_profile": "https://Stackoverflow.com/users/6297", "pm_score": 4, "selected": true, "text": "<p>You could unregister the control with</p>\n\n<pre><code>regsvr32 /u badboy.ocx\n</code></pre>\n\n<p>at the command line. Tho...
2008/10/07
[ "https://Stackoverflow.com/questions/180624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577/" ]
I'm developing a solution which uses an ActiveX control (a commercial one which we bought and that I did not develop). I need to develop the proper installation pages to simulate what happens when a user who has never visited the site and does not have the add-on installed comes to the page. I've found the "Manage Add...
You could unregister the control with ``` regsvr32 /u badboy.ocx ``` at the command line. Though i would suggest testing these things in a vmware.
180,626
<p>I am hosting a service within a Windows Service. </p> <p>The following snippet instantiates the ServiceHost object:</p> <pre><code>Host = new ServiceHost(typeof(Services.DocumentInfoService)); </code></pre> <p>The DocumentInfoService class implements a contract interface that has methods that invoke business obj...
[ { "answer_id": 180645, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "<p>Implement your own <code>ServiceHost</code>. See also <a href=\"http://hyperthink.net/blog/servicehostfactory-vs-serv...
2008/10/07
[ "https://Stackoverflow.com/questions/180626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7961/" ]
I am hosting a service within a Windows Service. The following snippet instantiates the ServiceHost object: ``` Host = new ServiceHost(typeof(Services.DocumentInfoService)); ``` The DocumentInfoService class implements a contract interface that has methods that invoke business objects requiring initialization (act...
ServiceHost will create the service instances based on the binding and behaviors configured for the endpoint. There's no particular point in time, where you can rely there is a service instance. Hence, ServiceHost does not expose the service instances. What you could do is add code to your service object constructor t...
180,647
<p>I am hoping to find a resource for lining up input elements in a HTML page. I find it difficult to get a select element and a text box to be the same width even when using the width style attribute, and it is even more difficult across browsers. Finally, file inputs seem impossible to get to the same width cross bro...
[ { "answer_id": 180656, "author": "Ron Savage", "author_id": 12476, "author_profile": "https://Stackoverflow.com/users/12476", "pm_score": 4, "selected": false, "text": "<p>I usually put them inside a div or table cell (horrors! I know) of the width I want, then set the select and input s...
2008/10/07
[ "https://Stackoverflow.com/questions/180647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18926/" ]
I am hoping to find a resource for lining up input elements in a HTML page. I find it difficult to get a select element and a text box to be the same width even when using the width style attribute, and it is even more difficult across browsers. Finally, file inputs seem impossible to get to the same width cross browse...
I tested this out in Internet Explorer 7, Firefox 3 and Safari/Google Chrome. I definitely see the problem with `<select>` and `<input type="file">`. My findings showed that if you styled all the inputs at the same width, the `<select>` would be about 5 pixels shorter in all browsers. Using the [Eric Meyer CSS reset s...
180,658
<p>When 'val' below is not a <code>bool</code> I get an exception, I believe I can use <code>TryParse</code> but I'm not sure how best to use it with my code below. Can anyone help?</p> <pre><code>checkBox.Checked = Convert.ToBoolean(val); </code></pre> <p>Thanks</p>
[ { "answer_id": 180663, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 4, "selected": false, "text": "<p>The code is as follows to determine whether the string <code>val</code> is a valid Boolean value and use it to set t...
2008/10/07
[ "https://Stackoverflow.com/questions/180658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When 'val' below is not a `bool` I get an exception, I believe I can use `TryParse` but I'm not sure how best to use it with my code below. Can anyone help? ``` checkBox.Checked = Convert.ToBoolean(val); ``` Thanks
The code is as follows to determine whether the string `val` is a valid Boolean value and use it to set the `Checked` property if so. You need to decide what action you would take if it does not represent a valid value. ``` bool result; if (bool.TryParse(val, out result)) { // val does represent a Boolean chec...
180,741
<p>How do you iterate over each file in a directory with a .bat or .cmd file?</p> <p>For simplicity please provide an answer that just echoes the filename or file path.</p>
[ { "answer_id": 180749, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 10, "selected": true, "text": "<p>Command line usage:</p>\n\n<pre><code>for /f %f in ('dir /b c:\\') do echo %f\n</code></pre>\n\n<p>Batch file usag...
2008/10/07
[ "https://Stackoverflow.com/questions/180741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
How do you iterate over each file in a directory with a .bat or .cmd file? For simplicity please provide an answer that just echoes the filename or file path.
Command line usage: ``` for /f %f in ('dir /b c:\') do echo %f ``` Batch file usage: ``` for /f %%f in ('dir /b c:\') do echo %%f ``` **Update**: if the directory contains files with space in the names, you need to change the delimiter the `for /f` command is using. for example, you can use the pipe char. ``` fo...
180,750
<p>Is there a way to take substrings of a string with .bat/.cmd files?</p> <p>For example given the string "hello.txt" is there a way to strip the .txt?</p> <p>EDIT: Also is there a more general way to do this, not under the assumption that it is a file name or file path?</p>
[ { "answer_id": 180766, "author": "Andrew", "author_id": 15127, "author_profile": "https://Stackoverflow.com/users/15127", "pm_score": 4, "selected": true, "text": "<p>If this is a file passed as a parameter, you can use %~n1, like this:</p>\n\n<pre><code>test.bat\n----------\necho %~n1 %...
2008/10/07
[ "https://Stackoverflow.com/questions/180750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
Is there a way to take substrings of a string with .bat/.cmd files? For example given the string "hello.txt" is there a way to strip the .txt? EDIT: Also is there a more general way to do this, not under the assumption that it is a file name or file path?
If this is a file passed as a parameter, you can use %~n1, like this: ``` test.bat ---------- echo %~n1 %~n2 c:\> test.bat myfile.txt my.long.file.bat myfile my.long.file ``` If you know the length of the string you can use the substring operator: ``` echo %variable:0,4% => "test.txt" => "test" ``` And to g...
180,760
<p>Can someone explain how to use if-then statements and for loops in Makefiles? I can't seem to find any good documentation with examples.</p>
[ { "answer_id": 180769, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "<p>Have you tried the <a href=\"http://www.gnu.org/software/make/manual/make.html#Conditionals\" rel=\"noreferrer\">GNU ma...
2008/10/07
[ "https://Stackoverflow.com/questions/180760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2039/" ]
Can someone explain how to use if-then statements and for loops in Makefiles? I can't seem to find any good documentation with examples.
**Conditional Forms** Simple ``` conditional-directive text-if-true endif ``` Moderately Complex ``` conditional-directive text-if-true else text-if-false endif ``` More Complex ``` conditional-directive text-if-one-is-true else conditional-directive text-if-true else text-if-false endif endif ``` **Condi...
180,777
<p>I have a ListBox which displays items of variable height. I want to show as many items as will fit in the available space, without showing a vertical scrollbar. Other than surgery on the ListBox item template, is there a way to only show the number of items which will fit without scrolling?</p>
[ { "answer_id": 180824, "author": "Brian Leahy", "author_id": 580, "author_profile": "https://Stackoverflow.com/users/580", "pm_score": 5, "selected": true, "text": "<pre><code> &lt;ListBox ScrollViewer.VerticalScrollBarVisibility=\"Auto\" /&gt; \n</code></pre>\n\n<p>the default is visibl...
2008/10/07
[ "https://Stackoverflow.com/questions/180777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5/" ]
I have a ListBox which displays items of variable height. I want to show as many items as will fit in the available space, without showing a vertical scrollbar. Other than surgery on the ListBox item template, is there a way to only show the number of items which will fit without scrolling?
``` <ListBox ScrollViewer.VerticalScrollBarVisibility="Auto" /> ``` the default is visible
180,793
<p>I need to clip out all the occurances of the pattern '--' that are <em>inside</em> single quotes in long string (leaving intact the ones that are outside single quotes). </p> <p>Is there a RegEx way of doing this? (using it with an iterator from the language is OK).</p> <p>For example, starting with</p> <pre><cod...
[ { "answer_id": 180798, "author": "levik", "author_id": 4465, "author_profile": "https://Stackoverflow.com/users/4465", "pm_score": 1, "selected": false, "text": "<p>This cannot be done with regular expressions, because you need to maintain state on whether you're inside single quotes or...
2008/10/07
[ "https://Stackoverflow.com/questions/180793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17251/" ]
I need to clip out all the occurances of the pattern '--' that are *inside* single quotes in long string (leaving intact the ones that are outside single quotes). Is there a RegEx way of doing this? (using it with an iterator from the language is OK). For example, starting with ``` "xxxx rt / $ 'dfdf--fggh-dfgdfg' ...
I found another way to do this from an answer by **Greg Hewgill** at [Qn138522](https://stackoverflow.com/questions/138552) It is based on using this regex (adapted to contain the pattern I was looking for): ``` --(?=[^\']*'([^']|'[^']*')*$) ``` Greg explains: > > "What this does is use the non-capturing match ...
180,796
<p>I have a servlet which is in the same web application as the JSF servlet. How do I replace (rather than redirect) the servlet response with the JSF response? </p>
[ { "answer_id": 180903, "author": "Martin", "author_id": 24364, "author_profile": "https://Stackoverflow.com/users/24364", "pm_score": 1, "selected": false, "text": "<p>Not sure I fully understand your question - but if you want to include the output from a JSF page in your servlet respon...
2008/10/07
[ "https://Stackoverflow.com/questions/180796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a servlet which is in the same web application as the JSF servlet. How do I replace (rather than redirect) the servlet response with the JSF response?
Not sure I fully understand your question - but if you want to include the output from a JSF page in your servlet response, something like: ``` public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { // Do stuff req.getRequestDispatcher("/blah.jsf").forward(r...
180,809
<p>Just wondering if there is an easy way to add the functionality to duplicate an existing listing in the admin interface?</p> <p>In data entry we have run into a situation where a lot of items share generic data with another item, and to save time it would be very nice to quickly duplicate an existing listing and on...
[ { "answer_id": 180816, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 8, "selected": true, "text": "<p>You can <a href=\"http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_as\...
2008/10/07
[ "https://Stackoverflow.com/questions/180809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23366/" ]
Just wondering if there is an easy way to add the functionality to duplicate an existing listing in the admin interface? In data entry we have run into a situation where a lot of items share generic data with another item, and to save time it would be very nice to quickly duplicate an existing listing and only alter t...
You can [save as](http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_as) by just enabling adding this to your ModelAdmin: ``` save_as = True ``` This replaces the "Save and add another" button with a "Save as" button. "Save as" means the object will be saved as a new object ...
180,841
<p>Here are some gems:</p> <p>Literals:</p> <pre><code>var obj = {}; // Object literal, equivalent to var obj = new Object(); var arr = []; // Array literal, equivalent to var arr = new Array(); var regex = /something/; // Regular expression literal, equivalent to var regex = new RegExp('something'); </code></pre> <...
[ { "answer_id": 180854, "author": "Chris Noe", "author_id": 14749, "author_profile": "https://Stackoverflow.com/users/14749", "pm_score": 5, "selected": false, "text": "<p>In Mozilla (and reportedly IE7) you can create an XML constant using:</p>\n\n<pre>\nvar xml = &lt;elem&gt;&lt;/elem&g...
2008/10/07
[ "https://Stackoverflow.com/questions/180841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17964/" ]
Here are some gems: Literals: ``` var obj = {}; // Object literal, equivalent to var obj = new Object(); var arr = []; // Array literal, equivalent to var arr = new Array(); var regex = /something/; // Regular expression literal, equivalent to var regex = new RegExp('something'); ``` Defaults: ``` arg = arg || 'de...
Getting the current datetime as milliseconds: ``` Date.now() ``` For example, to time the execution of a section of code: ``` var start = Date.now(); // some code alert((Date.now() - start) + " ms elapsed"); ```
180,844
<p>How would you reference the models (Accord, CRV, Prius, etc) in this structure? Is this a bad structure to be able to extract the makes...then use a make to get the models...then use the model to get the options?</p> <pre><code>var cars = [ { "makes" : "Honda", "models" : [ {'Ac...
[ { "answer_id": 180850, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 3, "selected": false, "text": "<p><strike> cars[0].models.Accord\n cars[0].models.CRV\n cars[0].models.Pilot</strike> (See <a href=\"h...
2008/10/07
[ "https://Stackoverflow.com/questions/180844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
How would you reference the models (Accord, CRV, Prius, etc) in this structure? Is this a bad structure to be able to extract the makes...then use a make to get the models...then use the model to get the options? ``` var cars = [ { "makes" : "Honda", "models" : [ {'Accord' : ["2dr"...
The structure: ``` var cars = [ { name: 'Honda', models: [ { name: 'Accord', features: ['2dr', '4dr'] }, { name: 'CRV', features: ['2dr', 'Hatchback'] }, { name: 'Pilot', features: ['base', 'superDuper'] } ]}, { name: 'Toyota', models: [ ...
180,853
<p>What is the maximum length for the text string contained in a CEdit control in MFC? I get a beep when trying to add a character after the character 30001 is this documented anywhere? Can I display longer texts in a CEdit? Should I use another control?</p> <p>As "Windows programmer" says down below, the text length ...
[ { "answer_id": 181345, "author": "ryan_s", "author_id": 13728, "author_profile": "https://Stackoverflow.com/users/13728", "pm_score": 3, "selected": false, "text": "<p>You can find out what the maximum is for your control by calling <a href=\"http://msdn.microsoft.com/en-us/library/xctw3...
2008/10/07
[ "https://Stackoverflow.com/questions/180853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14022/" ]
What is the maximum length for the text string contained in a CEdit control in MFC? I get a beep when trying to add a character after the character 30001 is this documented anywhere? Can I display longer texts in a CEdit? Should I use another control? As "Windows programmer" says down below, the text length limit is n...
I found the documentation is wrong when mentioning the default size for a single line CEdit control in vista. I ran this code: ``` CWnd* pWnd = dlg.GetDlgItem(nItemId); CEdit *edit = static_cast<CEdit*>(pWnd); //dynamic_cast does not work if(edit != 0) { UINT limit = edit->GetLimitText(); //The current text limit...
180,884
<p>When using </p> <pre><code>$('.foo').click(function(){ alert("I haz class alertz!"); return false; }); </code></pre> <p>in application.js, and</p> <pre><code>&lt;a href = "" class = "foo" id = "foobar_1" &gt;Teh Foobar &lt;/a&gt; </code></pre> <p>in any div that initializes with the page, when c...
[ { "answer_id": 180876, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 5, "selected": false, "text": "<p>We've used <a href=\"http://www.openssl.org/\" rel=\"noreferrer\">OpenSSL</a> with good success. Portable, standards c...
2008/10/07
[ "https://Stackoverflow.com/questions/180884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23885/" ]
When using ``` $('.foo').click(function(){ alert("I haz class alertz!"); return false; }); ``` in application.js, and ``` <a href = "" class = "foo" id = "foobar_1" >Teh Foobar </a> ``` in any div that initializes with the page, when clicking "Teh Foobar" it alerts and doesn't follow the link. Ho...
We've used [OpenSSL](http://www.openssl.org/) with good success. Portable, standards compliant and easy to use.
180,924
<p>Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app server), is there some way I can configure things so Tomcat will start with security turned on (i.e. as if I ran catalina.sh start -security)?</p>
[ { "answer_id": 180964, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 0, "selected": false, "text": "<p>I'm assuming that you're using Tomcat 5.5.x</p>\n\n<p>after looking at catalina.bat/catalina.sh, all the -security flag ...
2008/10/08
[ "https://Stackoverflow.com/questions/180924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app server), is there some way I can configure things so Tomcat will start with security turned on (i.e. as if I ran catalina.sh start -security)?
Go into 'Window' -> 'Preferences' then select 'Java' -> 'Installed JREs', clone the JRE used by Tomcat and add the following to the default VM Arguments ``` -Djava.security.manager -Djava.security.policy="XXXX\conf\catalina.policy" ``` With XXXX replaced by the appropriate path - Mine was `C:\Program Files\Apache So...
180,929
<p>I want to programmatically create a new column in an MS Access table. I've tried many permutations of <code>ALTER TABLE MyTable Add MyField DECIMAL (9,4) NULL;</code> and got: </p> <blockquote> <p>Syntax Error in Field Definition</p> </blockquote> <p>I can easily create a number field that goes to a <code>Doub...
[ { "answer_id": 180980, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": false, "text": "<p>The ALTER TABLE syntax is only supported in Jet 4.0/ACE while in\nANSI-92 Query Mode. Try an ADO connection e.g.</p...
2008/10/08
[ "https://Stackoverflow.com/questions/180929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12897/" ]
I want to programmatically create a new column in an MS Access table. I've tried many permutations of `ALTER TABLE MyTable Add MyField DECIMAL (9,4) NULL;` and got: > > Syntax Error in Field Definition > > > I can easily create a number field that goes to a `Double` type, but I want `decimal`. I would very stron...
If you want to create a new column in an acces table, it is easy to use the DAO.tableDef object: ``` Dim my_tableDef As DAO.TableDef Dim my_field As DAO.Field Set my_tableDef = currentDb.TableDefs(my_table) Set my_Field = my_tableDef.CreateField(my_fieldName, dbDecimal, myFieldSize) my_Field.decimalPlaces = myDecimal...
180,930
<p>I am attempting to use linq to shape list of data into a particular shape to be returned as Json from an ajax call.</p> <p>Given this data:</p> <pre><code>var data = new List&lt;string&gt;(); data.Add("One"); data.Add("Two"); data.Add("Three"); </code></pre> <p>And this code: ** Which is not correct and is what n...
[ { "answer_id": 180980, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": false, "text": "<p>The ALTER TABLE syntax is only supported in Jet 4.0/ACE while in\nANSI-92 Query Mode. Try an ADO connection e.g.</p...
2008/10/08
[ "https://Stackoverflow.com/questions/180930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/410357/" ]
I am attempting to use linq to shape list of data into a particular shape to be returned as Json from an ajax call. Given this data: ``` var data = new List<string>(); data.Add("One"); data.Add("Two"); data.Add("Three"); ``` And this code: \*\* Which is not correct and is what needs to be fixed!! \*\* ``` var shap...
If you want to create a new column in an acces table, it is easy to use the DAO.tableDef object: ``` Dim my_tableDef As DAO.TableDef Dim my_field As DAO.Field Set my_tableDef = currentDb.TableDefs(my_table) Set my_Field = my_tableDef.CreateField(my_fieldName, dbDecimal, myFieldSize) my_Field.decimalPlaces = myDecimal...
180,935
<p>I've got a LOT of tests written for a piece of software (which is a GREAT thing) but it was built essentially as a standalone test in C#. While this works well enough, it suffers from a few shortcomings, not the least of which is that it isn't using a standard testing framework and ends up requiring the person runn...
[ { "answer_id": 180966, "author": "Jonathan Beerhalter", "author_id": 18927, "author_profile": "https://Stackoverflow.com/users/18927", "pm_score": 1, "selected": false, "text": "<p>You're about to live through the idiom of \"An Ounce of Prevention is worth a pound of cure\". Its especial...
2008/10/08
[ "https://Stackoverflow.com/questions/180935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7862/" ]
I've got a LOT of tests written for a piece of software (which is a GREAT thing) but it was built essentially as a standalone test in C#. While this works well enough, it suffers from a few shortcomings, not the least of which is that it isn't using a standard testing framework and ends up requiring the person running ...
If you use NUnit (which you should), you'll need to create a new test method for each of your current test methods. NUnit uses reflection to query the test class for methods marked with the `[Test]` attribute, which is how it builds its list of the tests that show up in the UI, and the test classes use the NUnit `Asser...
180,947
<p>Is there a freely available Base64 decoding code snippet in C++?</p>
[ { "answer_id": 180949, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 8, "selected": true, "text": "<p>See <em><a href=\"http://www.adp-gmbh.ch/cpp/common/base64.html\" rel=\"noreferrer\">Encoding and decoding base 64 w...
2008/10/08
[ "https://Stackoverflow.com/questions/180947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19104/" ]
Is there a freely available Base64 decoding code snippet in C++?
See *[Encoding and decoding base 64 with C++](http://www.adp-gmbh.ch/cpp/common/base64.html)*. Here is the implementation from that page: ``` /* base64.cpp and base64.h Copyright (C) 2004-2008 René Nyffenegger This source code is provided 'as-is', without any express or implied warranty. In no event wil...
180,979
<p>I am getting very frustrated because I cannot seem to figure out why Collections shuffling is not working properly.</p> <p>Lets say that I am trying to shuffle the <code>randomizer</code> array. </p> <pre><code>int[] randomizer = new int[] {200,300,212,111,6,2332}; Collections.shuffle(Arrays.asList(randomizer));...
[ { "answer_id": 180990, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": true, "text": "<p><code>Arrays.asList</code> cannot be used with arrays of primitives. Use this instead:</p>\n\n<pre><code>Integer[] randomi...
2008/10/08
[ "https://Stackoverflow.com/questions/180979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14013/" ]
I am getting very frustrated because I cannot seem to figure out why Collections shuffling is not working properly. Lets say that I am trying to shuffle the `randomizer` array. ``` int[] randomizer = new int[] {200,300,212,111,6,2332}; Collections.shuffle(Arrays.asList(randomizer)); ``` For some reason the elemen...
`Arrays.asList` cannot be used with arrays of primitives. Use this instead: ``` Integer[] randomizer = new Integer[] {200,300,212,111,6,2332}; Collections.shuffle(Arrays.asList(randomizer)); ``` The same rule applies to most classes in the collections framework, in that you can't use primitive types. The original ...
180,986
<p>What is the difference between the <code>search()</code> and <code>match()</code> functions in the Python <code>re</code> module?</p> <p>I've read the <a href="https://docs.python.org/2/library/re.html?highlight=matching%20searching#search-vs-match" rel="nofollow noreferrer">Python 2 documentation</a> (<a href="http...
[ { "answer_id": 180993, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 10, "selected": true, "text": "<p><code>re.match</code> is anchored at the beginning of the string. That has nothing to do with newlines, so it is not the...
2008/10/08
[ "https://Stackoverflow.com/questions/180986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766/" ]
What is the difference between the `search()` and `match()` functions in the Python `re` module? I've read the [Python 2 documentation](https://docs.python.org/2/library/re.html?highlight=matching%20searching#search-vs-match) ([Python 3 documentation](https://docs.python.org/3/library/re.html#search-vs-match)), but I ...
`re.match` is anchored at the beginning of the string. That has nothing to do with newlines, so it is not the same as using `^` in the pattern. As the [re.match documentation](http://docs.python.org/2/library/re.html#re.match) says: > > If zero or more characters at the > **beginning of string** match the regular e...
181,018
<p>My application has no forms. It runs by calling Application.Run();</p>
[ { "answer_id": 181020, "author": "Haim Bender", "author_id": 44972, "author_profile": "https://Stackoverflow.com/users/44972", "pm_score": 3, "selected": true, "text": "<p>Call </p>\n\n<pre><code>System.Windows.Forms.Application.Exit();\n</code></pre>\n" }, { "answer_id": 181098,...
2008/10/08
[ "https://Stackoverflow.com/questions/181018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44972/" ]
My application has no forms. It runs by calling Application.Run();
Call ``` System.Windows.Forms.Application.Exit(); ```
181,029
<p>Has anyone been able to implement the JQuery grid plugin, jqGrid? I'm trying to implement the JSON paging, and I feel like I'm getting close, but that I am also being swamped by inconsequential details. If anyone could post some sample code, I would greatly appreciate it.</p>
[ { "answer_id": 181072, "author": "tsimon", "author_id": 1685, "author_profile": "https://Stackoverflow.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>I'm just floundering trying to pull everything together. My first concern is simply generating a correct JSON response. My...
2008/10/08
[ "https://Stackoverflow.com/questions/181029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1685/" ]
Has anyone been able to implement the JQuery grid plugin, jqGrid? I'm trying to implement the JSON paging, and I feel like I'm getting close, but that I am also being swamped by inconsequential details. If anyone could post some sample code, I would greatly appreciate it.
Found your post while I was trying to do this for my project. I got it working. For anyone who needs it in the future, jqGrid won't work out of the box with JSON and ASP.NET. You need to make a couple of small modifications to grid.base.js. Around line 829, replace the json case section with the following: ``` case "j...
181,036
<p>I'm trying to get this simple PowerShell script working, but I think something is fundamentally wrong. ;-)</p> <pre><code>ls | ForEach { &quot;C:\Working\tools\custom-tool.exe&quot; $_ } </code></pre> <p>I basically want to get files in a directory, and pass them one by one as arguments to the custom tool.</p>
[ { "answer_id": 181065, "author": "slipsec", "author_id": 1635, "author_profile": "https://Stackoverflow.com/users/1635", "pm_score": 6, "selected": true, "text": "<pre><code>ls | %{C:\\Working\\tools\\custom-tool.exe $_}\n</code></pre>\n\n<p>As each object comes down the pipeline the too...
2008/10/08
[ "https://Stackoverflow.com/questions/181036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18437/" ]
I'm trying to get this simple PowerShell script working, but I think something is fundamentally wrong. ;-) ``` ls | ForEach { "C:\Working\tools\custom-tool.exe" $_ } ``` I basically want to get files in a directory, and pass them one by one as arguments to the custom tool.
``` ls | %{C:\Working\tools\custom-tool.exe $_} ``` As each object comes down the pipeline the tool will be run against it. Putting quotes around the command string causes it to be... a string! The local variable "$\_" it then likely doesn't know what to do with so pukes with an error.
181,037
<p>I am looking for a method to compare and sort UTF-8 strings in C++ in a case-insensitive manner to use it in a <a href="http://www.sqlite.org/c3ref/create_collation.html" rel="noreferrer">custom collation function in SQLite</a>.</p> <ol> <li>The method should <em>ideally</em> be locale-independent. However I won't ...
[ { "answer_id": 181129, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 0, "selected": false, "text": "<p>I don't think there's a standard C/C++ library function you can use. You'll have to roll your own or use a 3rd-p...
2008/10/08
[ "https://Stackoverflow.com/questions/181037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23643/" ]
I am looking for a method to compare and sort UTF-8 strings in C++ in a case-insensitive manner to use it in a [custom collation function in SQLite](http://www.sqlite.org/c3ref/create_collation.html). 1. The method should *ideally* be locale-independent. However I won't be holding my breath, as far as I know, collatio...
What you really want is logically impossible. There is no locale-independent, case-insensitive way of sorting strings. The simple counter-example is "i" <> "I" ? The naive answer is no, but in Turkish these strings are unequal. "i" is uppercased to "İ" (U+130 Latin Capital I with dot above) UTF-8 strings add extra com...
181,064
<p>For my current C++ project I need to detect a unique string for every monitor that is connected and active on a large number of computers. </p> <p>Research has pointed to 2 options</p> <ol> <li><p>Use WMI and query the Win32_DesktopMonitor for all active monitors. Use the PNPDeviceID for unique identification of m...
[ { "answer_id": 183284, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 0, "selected": false, "text": "<p>I've never tried doing it from a service, but <code>EnumDisplayDevices</code> generally works well when run as a user...
2008/10/08
[ "https://Stackoverflow.com/questions/181064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
For my current C++ project I need to detect a unique string for every monitor that is connected and active on a large number of computers. Research has pointed to 2 options 1. Use WMI and query the Win32\_DesktopMonitor for all active monitors. Use the PNPDeviceID for unique identification of monitors. 2. Use the En...
This is my current work-in-progress code for detecting the monitor device id, reliably. ``` CString DeviceID; DISPLAY_DEVICE dd; dd.cb = sizeof(dd); DWORD dev = 0; // device index int id = 1; // monitor number, as used by Display Properties > Settings while (EnumDisplayDevices(0, dev, &dd, 0)) { DISPLAY_DEV...
181,082
<p>I have followed all the instructions here: <a href="http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/" rel="noreferrer">http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/</a></p> <p>to install &amp; config apache get the PHP5 packages and get the CURL packages.</p> ...
[ { "answer_id": 181220, "author": "boxoft", "author_id": 23773, "author_profile": "https://Stackoverflow.com/users/23773", "pm_score": 4, "selected": false, "text": "<p>I'm using XAMPP, in which there are several php.ini files.</p>\n\n<p>You can find the line in the php.ini files:\n<code>...
2008/10/08
[ "https://Stackoverflow.com/questions/181082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/196874/" ]
I have followed all the instructions here: <http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/> to install & config apache get the PHP5 packages and get the CURL packages. I run the apache and run a PHP script. no problem. but when I run the php script with curl, it fails. It returns: `**Cal...
You're probably mistaking what PHP.ini you need to edit. first, add a PHPinfo(); to a info.php, and run it from your browser. Write down the PHP ini directory path you see in the variables list now! You will probably notice that it's different from your PHP-CLI ini file. Enable the extension You're done :-)
181,090
<p>I have a tree of active record objects, something like:</p> <pre><code>class Part &lt; ActiveRecord::Base has_many :sub_parts, :class_name =&gt; "Part" def complicated_calculation if sub_parts.size &gt; 0 return self.sub_parts.inject(0){ |sum, current| sum + current.complicated_calculation } else...
[ { "answer_id": 181093, "author": "epochwolf", "author_id": 16204, "author_profile": "https://Stackoverflow.com/users/16204", "pm_score": 2, "selected": false, "text": "<p>Have a field similar to a counter cache. For example: order_items_amount and have that be a cached calculated field. ...
2008/10/08
[ "https://Stackoverflow.com/questions/181090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23899/" ]
I have a tree of active record objects, something like: ``` class Part < ActiveRecord::Base has_many :sub_parts, :class_name => "Part" def complicated_calculation if sub_parts.size > 0 return self.sub_parts.inject(0){ |sum, current| sum + current.complicated_calculation } else sleep(1) r...
1. You can stuff the actually cached values in the Rails cache (use memcached if you require that it be distributed). 2. The tough bit is cache expiry, but cache expiry is uncommon, right? In that case, we can just loop over each of the parent objects in turn and zap its cache, too. I added some ActiveRecord magic to y...
181,091
<p>I have an array of hashes, and I want the unique values out of it. Calling <code>Array.uniq</code> doesn't give me what I expect.</p> <pre><code>a = [{:a =&gt; 1},{:a =&gt; 2}, {:a =&gt; 1}] a.uniq # =&gt; [{:a =&gt; 1}, {:a =&gt; 2}, {:a =&gt; 1}] </code></pre> <p>Where I expected:</p> <pre><code>[{:a =&gt; 1},...
[ { "answer_id": 181096, "author": "Aaron Hinni", "author_id": 12086, "author_profile": "https://Stackoverflow.com/users/12086", "pm_score": 6, "selected": true, "text": "<p>I can get what I want by calling <code>inject</code></p>\n\n<pre><code>a = [{:a =&gt; 1},{:a =&gt; 2}, {:a =&gt; 1}]...
2008/10/08
[ "https://Stackoverflow.com/questions/181091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12086/" ]
I have an array of hashes, and I want the unique values out of it. Calling `Array.uniq` doesn't give me what I expect. ``` a = [{:a => 1},{:a => 2}, {:a => 1}] a.uniq # => [{:a => 1}, {:a => 2}, {:a => 1}] ``` Where I expected: ``` [{:a => 1}, {:a => 2}] ``` In searching around on the net, I didn't come up with a...
I can get what I want by calling `inject` ``` a = [{:a => 1},{:a => 2}, {:a => 1}] a.inject([]) { |result,h| result << h unless result.include?(h); result } ``` This will return: ``` [{:a=>1}, {:a=>2}] ```
181,097
<p>I wanted to do something like this:</p> <pre><code>&lt;asp:Label ID="lblMyLabel" onclick="lblMyLabel_Click" runat="server"&gt;My Label&lt;/asp:Label&gt; </code></pre> <p>I know that in Javascript I can do:</p> <pre><code>&lt;span onclick="foo();"&gt;My Label&lt;/span&gt; </code></pre> <p>So I'm wondering why I c...
[ { "answer_id": 181103, "author": "Brian Kim", "author_id": 5704, "author_profile": "https://Stackoverflow.com/users/5704", "pm_score": 7, "selected": true, "text": "<p>You can use Attributes to add onclick client side callback.</p>\n\n<p>I didn't know you can do this on span tags, but if...
2008/10/08
[ "https://Stackoverflow.com/questions/181097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10708/" ]
I wanted to do something like this: ``` <asp:Label ID="lblMyLabel" onclick="lblMyLabel_Click" runat="server">My Label</asp:Label> ``` I know that in Javascript I can do: ``` <span onclick="foo();">My Label</span> ``` So I'm wondering why I can't do that with a Label object.
You can use Attributes to add onclick client side callback. I didn't know you can do this on span tags, but if it works you can add 'onclick' by `lblMyLabel.Attributes.Add("onclick", "foo();");` But `foo();` would need to be a client side javascript function. `System.Web.UI.WebControls.Label` does NOT have OnClick ...
181,106
<p>Is a new (or different) instance of <code>TestCase</code> object is used to run each test method in a JUnit test case? Or one instance is reused for all the tests?</p> <pre><code>public class MyTest extends TestCase { public void testSomething() { ... } public void testSomethingElse() { ... } } </code></pre> ...
[ { "answer_id": 181111, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 3, "selected": false, "text": "<p>Yes, a separate instance is created.</p>\n\n<p>While running that test, 2 instances of MyTest gets created.</p>\n\n<p>If...
2008/10/08
[ "https://Stackoverflow.com/questions/181106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13326/" ]
Is a new (or different) instance of `TestCase` object is used to run each test method in a JUnit test case? Or one instance is reused for all the tests? ``` public class MyTest extends TestCase { public void testSomething() { ... } public void testSomethingElse() { ... } } ``` While running this test, how many i...
I couldn't find a clear answer in the JUnit docs about your question, but the intent, as anjanb wrote, is that each test is independent of the others, so a new TestCase instance could be created for each test to be run. If you have expensive test setup ("*fixtures*") that you want to be shared across all test cases in...
181,132
<p>On my homepage I got:</p> <pre><code>&lt;ul id="login"&gt; &lt;li&gt; &lt;a id="loginswitch" href="./login-page"&gt;log-in&lt;/a&gt; | &lt;/li&gt; &lt;li&gt; &lt;a id="signupswitch" href="./signup-page"&gt;sign-up&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Via MooTools, I get these anchor elements by i...
[ { "answer_id": 181137, "author": "ephemient", "author_id": 20713, "author_profile": "https://Stackoverflow.com/users/20713", "pm_score": 1, "selected": false, "text": "<p>Going to an anchor on a page -- which is what <code>#</code> signifies -- does not require a reload.</p>\n" }, { ...
2008/10/08
[ "https://Stackoverflow.com/questions/181132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24744/" ]
On my homepage I got: ``` <ul id="login"> <li> <a id="loginswitch" href="./login-page">log-in</a> | </li> <li> <a id="signupswitch" href="./signup-page">sign-up</a> </li> </ul> ``` Via MooTools, I get these anchor elements by id so that once they're clicked, a flashy div will popup below them that contains the l...
``` window.location = self.location; ``` **This JavaScript is executing**. When it executes, the browser is being told to replace the value of `window.location` with a new value. **Not all browsers** will react the same way here. Some will probably work as you expect, but others will get smart about it and compare t...
181,136
<p>I have a text file with multiple records. I want to search a name and date, for example if I typed <code>JULIUS CESAR</code> as name then the whole data about <code>JULIUS</code> will be extracted. What if I want only to extract information?</p> <pre><code>Record number: 1 Date: 08-Oct-08 Time: 23:45:01 Name: JULIU...
[ { "answer_id": 181156, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>If it is one line per entry, you could use a regular expression such as:</p>\n\n<pre><code>$name = \"JULIUS CESAR\";\n</cod...
2008/10/08
[ "https://Stackoverflow.com/questions/181136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a text file with multiple records. I want to search a name and date, for example if I typed `JULIUS CESAR` as name then the whole data about `JULIUS` will be extracted. What if I want only to extract information? ``` Record number: 1 Date: 08-Oct-08 Time: 23:45:01 Name: JULIUS CESAR Address: BAGUIO CITY, Philip...
If it is one line per entry, you could use a regular expression such as: ``` $name = "JULIUS CESAR"; ``` Then use: ``` /$name/i ``` to test if each line is about "JULIUS CESAR." Then you simply have to use the following regex to extract the information (once you find the line): ``` /Record number: (\d+) Date: ...
181,158
<p>i have a databound GridView in asp.net 2.0 with a row-selection link. When a row is selected, I want to programmatically add a table row below the selected row, in order to nest another grid et al.</p> <p>I am researching this for a client and for an article, and i think my google-fu is not strong tonight. Any sugg...
[ { "answer_id": 181168, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 4, "selected": true, "text": "<p>I think I figured it out. Here is a solution that seems to work. It could be improved using user controls but this ...
2008/10/08
[ "https://Stackoverflow.com/questions/181158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9345/" ]
i have a databound GridView in asp.net 2.0 with a row-selection link. When a row is selected, I want to programmatically add a table row below the selected row, in order to nest another grid et al. I am researching this for a client and for an article, and i think my google-fu is not strong tonight. Any suggestions? ...
I think I figured it out. Here is a solution that seems to work. It could be improved using user controls but this is the gist of it: ``` protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState....
181,159
<p>I'm trying to generate a unique ID in php in order to store user-uploaded content on a FS without conflicts. I'm using php, and at the moment this little snippet is responsible for generating the UID:</p> <pre><code>$id = tempnam (".", ""); unlink($id); $id = substr($id, 2); </code></pre> <p>This code is hideous:...
[ { "answer_id": 181162, "author": "Robert Elwell", "author_id": 23102, "author_profile": "https://Stackoverflow.com/users/23102", "pm_score": 3, "selected": false, "text": "<p>uniqid() is what you're looking for in most practical situations.</p>\n\n<p>You can make it even more \"uniq\" by...
2008/10/08
[ "https://Stackoverflow.com/questions/181159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1266/" ]
I'm trying to generate a unique ID in php in order to store user-uploaded content on a FS without conflicts. I'm using php, and at the moment this little snippet is responsible for generating the UID: ``` $id = tempnam (".", ""); unlink($id); $id = substr($id, 2); ``` This code is hideous: it creates a temporary fil...
``` string uniqid ([ string $prefix [, bool $more_entropy ]] ) ``` Gets a prefixed unique identifier based on the current time in microseconds. ``` USAGE: $id = uniqid(rand(), true); ```
181,188
<p>In VB.NET I often <code>Catch…When</code>:</p> <pre><code>Try … Catch e As ArgumentNullException When e.ParamName.ToUpper() = "SAMPLES" … End Try </code></pre> <p>Is there a C# equivalent to <code>Catch…When</code>?</p> <p>I don't want to resort to using an <code>if</code> statement inside a <code>catch</...
[ { "answer_id": 181190, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 4, "selected": false, "text": "<p>There's no equivalent to <code>Catch…When</code> in C#. You will really have to resort to an <code>if</code> statement in...
2008/10/08
[ "https://Stackoverflow.com/questions/181188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8280/" ]
In VB.NET I often `Catch…When`: ``` Try … Catch e As ArgumentNullException When e.ParamName.ToUpper() = "SAMPLES" … End Try ``` Is there a C# equivalent to `Catch…When`? I don't want to resort to using an `if` statement inside a `catch` if possible.
This functionality was announced for C# 6. It is now possible to write ``` try { … } catch (MyException e) when (myfilter(e)) { … } ``` You can download the preview of [Visual Studio 2015](http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx) now to check this out, or wait for the off...
181,189
<p>After being through numerous forums available on the net for last 5 days, I am still not able to completely track down the browser close event. My requirement is to generate a popup message, when user tries to close the browser.</p> <p>I have called my javascript function on body 'onbeforeunload' event. And I have h...
[ { "answer_id": 181944, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 4, "selected": false, "text": "<p>The question isn't an unusual one. Yet after 5 days searching the internet you still haven't found a satisfactor...
2008/10/08
[ "https://Stackoverflow.com/questions/181189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
After being through numerous forums available on the net for last 5 days, I am still not able to completely track down the browser close event. My requirement is to generate a popup message, when user tries to close the browser. I have called my javascript function on body 'onbeforeunload' event. And I have hardcoded ...
The question isn't an unusual one. Yet after 5 days searching the internet you still haven't found a satisfactory answer. That in itself should be a fairly plain indicator. What I've found on the web is there is a serious aversion to the 'no can do' answer. When something can't be done the normal response is to make n...
181,191
<p>Let me preface this by saying I'm a complete amateur when it comes to RegEx and only started a few days ago. I'm trying to solve a problem formatting a file and have hit a hitch with a particular type of data. The input file is structured like this:</p> <pre> Two words,Word,Word,Word,"Number, number" </pre> <p>Wha...
[ { "answer_id": 181208, "author": "ephemient", "author_id": 20713, "author_profile": "https://Stackoverflow.com/users/20713", "pm_score": 2, "selected": true, "text": "<p><code>s/,([^ ])/\",\"$1/</code> will match a \"<code>,</code>\" followed by a \"not-a-space\", capturing the not-a-spa...
2008/10/08
[ "https://Stackoverflow.com/questions/181191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25045/" ]
Let me preface this by saying I'm a complete amateur when it comes to RegEx and only started a few days ago. I'm trying to solve a problem formatting a file and have hit a hitch with a particular type of data. The input file is structured like this: ``` Two words,Word,Word,Word,"Number, number" ``` What I need to d...
`s/,([^ ])/","$1/` will match a "`,`" followed by a "not-a-space", capturing the not-a-space, then replacing the whole thing with the captured part. Depending on which regex engine you're using, you might be writing `\1` or other things instead of `$1`. If you're using Perl or otherwise have access to a regex engine ...
181,209
<p>I have a function that looks like this</p> <pre><code>class NSNode { function insertAfter(NSNode $node) { ... } } </code></pre> <p>I'd like to be able to use that function to indicate that the node is being inserted at the start, therefore it is after <em>nothing</em>. The way I think about that is...
[ { "answer_id": 181218, "author": "Geoff", "author_id": 10427, "author_profile": "https://Stackoverflow.com/users/10427", "pm_score": 1, "selected": false, "text": "<p>No, you can't pass something else to the function as that defeats the purpose of the static typing. In this situation, s...
2008/10/08
[ "https://Stackoverflow.com/questions/181209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I have a function that looks like this ``` class NSNode { function insertAfter(NSNode $node) { ... } } ``` I'd like to be able to use that function to indicate that the node is being inserted at the start, therefore it is after *nothing*. The way I think about that is that `null` means "nothing", so ...
sure, just set a default "null" ``` function(NSNode $node = null) { // stuff.... } ``` result being: ``` $obj->insertAfter(); // no error $obj->insertAfter(new NSNode); // no error $obj->insertAfter($somevar); // error expected NSNode ```
181,210
<p>I have an asp.net text form that contains numerous decimal fields that are optional. I want to selectively update the database but not inserting a "0" for fields that do not have data (maintaining the null status). </p> <p>Typically, I would create multiple functions, each with a different signature to handle this....
[ { "answer_id": 181229, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 1, "selected": false, "text": "<p>You could use the <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.dbnull\" rel=\"nofollow noreferrer\">DBN...
2008/10/08
[ "https://Stackoverflow.com/questions/181210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3149/" ]
I have an asp.net text form that contains numerous decimal fields that are optional. I want to selectively update the database but not inserting a "0" for fields that do not have data (maintaining the null status). Typically, I would create multiple functions, each with a different signature to handle this. However, ...
[Nullable Types](http://msdn.microsoft.com/en-us/library/b3h38hb0(VS.80).aspx) are meant for the same purpose. They represent value types with the possibility of having no data in them. Presence of value can be checked using HasValue property of these types. Pseudo code to read the fields: ``` decimal? dValue; // def...
181,212
<p>Ok, this is a weird one. The junk data isn't random either, it appears to be substrings of the executable itself.</p> <pre><code>private void Form1_Load(object sender, EventArgs e) { string s = GetValue(); // at this point, s == "400". Why isn't really relevant (dumbed down a test) if (s != "18446744073...
[ { "answer_id": 181244, "author": "Ryan Taylor", "author_id": 6231, "author_profile": "https://Stackoverflow.com/users/6231", "pm_score": 0, "selected": false, "text": "<p>If you're checking the variable after the exception has been thrown and is now out of scope, then it should be pointi...
2008/10/08
[ "https://Stackoverflow.com/questions/181212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
Ok, this is a weird one. The junk data isn't random either, it appears to be substrings of the executable itself. ``` private void Form1_Load(object sender, EventArgs e) { string s = GetValue(); // at this point, s == "400". Why isn't really relevant (dumbed down a test) if (s != "18446744073709551615") ...
"And I'm checking it in the "Locals" window in VS" That explains it. Contrary to popular belief, C# is allowed to do some amount of optimization. If you don't add a "KeepAlive" at the end of your function, the value doesn't really have to be stored.
181,214
<p>Implementing a file upload under html is fairly simple, but I just noticed that there is an 'accept' attribute that can be added to the <code>&lt;input type="file" ...&gt;</code> tag.</p> <p>Is this attribute useful as a way of limiting file uploads to images, etc? What is the best way to use it?</p> <p>Alternativ...
[ { "answer_id": 181291, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 5, "selected": false, "text": "<p>Accept attribute was introduced in the <a href=\"https://www.rfc-editor.org/rfc/rfc1867\" rel=\"nofollow nor...
2008/10/08
[ "https://Stackoverflow.com/questions/181214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/691/" ]
Implementing a file upload under html is fairly simple, but I just noticed that there is an 'accept' attribute that can be added to the `<input type="file" ...>` tag. Is this attribute useful as a way of limiting file uploads to images, etc? What is the best way to use it? Alternatively, is there a way to limit file ...
The `accept` attribute is incredibly useful. It is a hint to browsers to only show files that are allowed for the current `input`. While it can typically be overridden by users, it helps narrow down the results for users by default, so they can get exactly what they're looking for without having to sift through a hundr...
181,222
<p>I have a script which calls <code>mysql_connect()</code> to connect to a MySQL DB. When I run the script in a browser, it works. However, when I run it from a command line I receive the following error:</p> <pre><code>Call to undefined function mysql_connect() </code></pre> <p>This seems completely paradoxical. A...
[ { "answer_id": 181233, "author": "Robert Elwell", "author_id": 23102, "author_profile": "https://Stackoverflow.com/users/23102", "pm_score": 2, "selected": false, "text": "<p>While it may be a rudimentary answer, make sure you have the most up to date PHP client, and make sure that it's ...
2008/10/08
[ "https://Stackoverflow.com/questions/181222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24059/" ]
I have a script which calls `mysql_connect()` to connect to a MySQL DB. When I run the script in a browser, it works. However, when I run it from a command line I receive the following error: ``` Call to undefined function mysql_connect() ``` This seems completely paradoxical. Anyone have any ideas as how I can run ...
It maybe using a default PHP configuration. I have found before that it doesn't use the same php.ini or doesn't use one at all. Therefore some of the extensions won't be enabled. Do this instead: ``` php -c /etc/php.ini /path/to/script.php ``` Where `/etc/php.ini` is the path to your ini file. You can find this by ...
181,225
<p>I'm looking for a reasonably fast event handling mechanism in Java to generate and handle events across different JVMs running on different hosts.</p> <p>For event handling across multiple threads in a single JVM, I found some good candidates like Jetlang. But in my search for a distributed equivalent , I couldn't ...
[ { "answer_id": 181331, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 2, "selected": false, "text": "<p>AMQP(Advanced Message Queuing Protocol ) -- more details :\n<a href=\"http://en.wikipedia.org/wiki/Advanced_Message_Queu...
2008/10/08
[ "https://Stackoverflow.com/questions/181225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21647/" ]
I'm looking for a reasonably fast event handling mechanism in Java to generate and handle events across different JVMs running on different hosts. For event handling across multiple threads in a single JVM, I found some good candidates like Jetlang. But in my search for a distributed equivalent , I couldn't find anyth...
[Hazelcast](http://www.hazelcast.com) Topic is a distributed pub-sub messaging solution. ``` public class Sample implements MessageListener { public static void main(String[] args) { Sample sample = new Sample(); Topic topic = Hazelcast.getTopic ("default"); topic.addMessageListener(sam...
181,226
<p>I am using an authentication attribute on some of my actions in an asp.net mvc page to refer people to a login screen if they have not authenticated. My problem is returning them to the referring page after they have logged in. I was just keeping track of the referring action and referring controller but that beco...
[ { "answer_id": 181774, "author": "Casper", "author_id": 18729, "author_profile": "https://Stackoverflow.com/users/18729", "pm_score": 2, "selected": false, "text": "<p>What I did to achieve that result might be overdoing it, and I'd like to see some other methods as well. However, here's...
2008/10/08
[ "https://Stackoverflow.com/questions/181226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/361/" ]
I am using an authentication attribute on some of my actions in an asp.net mvc page to refer people to a login screen if they have not authenticated. My problem is returning them to the referring page after they have logged in. I was just keeping track of the referring action and referring controller but that becomes p...
In case you're using FormsAuthentication, when ASP.NET redirects a user to the login page, the URL looks something like this: ``` http://www.mysite.com/Login?ReturnUrl=/Something ``` The login form's action attribute should have the same ReturnUrl parameter (either as hidden input or as part of Url) so that FormsAut...
181,241
<p>Every time I use the "at" command, I get this message:</p> <pre><code>warning: commands will be executed using /bin/sh </code></pre> <p>What is it trying to warn me about? More importantly, how do I turn the warning off?</p>
[ { "answer_id": 181245, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 4, "selected": false, "text": "<p>It serves as a good warning to those of us that don't use bash as our shell, because we we'll forget that a feature that'...
2008/10/08
[ "https://Stackoverflow.com/questions/181241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
Every time I use the "at" command, I get this message: ``` warning: commands will be executed using /bin/sh ``` What is it trying to warn me about? More importantly, how do I turn the warning off?
It serves as a good warning to those of us that don't use bash as our shell, because we we'll forget that a feature that's in our day-to-day shell isn't going to be available when this code is run at the appointed time. i.e. ``` username@hostname$ at 23:00 warning: commands will be executed using /bin/sh at> rm...