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 |
|---|---|---|---|---|---|---|
273,261 | <p>I have an application where I accept a socket connection from a telnet client and put up a simple, keyboard driven character GUI.</p>
<p>The telnet client, at least on Linux, defaults into line-at-a-time mode, so I always have to do <code>^]mode char</code> manually.</p>
<p>A skim of the relevant RFCs suggests tha... | [
{
"answer_id": 279271,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>For what it's worth, solved it myself.</p>\n\n<pre><code>// IAC WONT LINEMODE IAC WILL ECHO\n\nwrite(s,\"\\377\\375\\042\\3... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an application where I accept a socket connection from a telnet client and put up a simple, keyboard driven character GUI.
The telnet client, at least on Linux, defaults into line-at-a-time mode, so I always have to do `^]mode char` manually.
A skim of the relevant RFCs suggests that if my application simply s... | For what it's worth, solved it myself.
```
// IAC WONT LINEMODE IAC WILL ECHO
write(s,"\377\375\042\377\373\001",6);
```
gets the remote (at least telnet from an Xterm on a Linux box) into the right state. |
273,262 | <p>I want to deal with the command line input in Ruby:</p>
<pre><code>> cat input.txt | myprog.rb
> myprog.rb < input.txt
> myprog.rb arg1 arg2 arg3 ...
</code></pre>
<p>What is the best way to do it? In particular I want to deal with blank STDIN, and I hope for an elegant solution.</p>
<pre><code>#!/usr... | [
{
"answer_id": 273415,
"author": "Damir Zekić",
"author_id": 401510,
"author_profile": "https://Stackoverflow.com/users/401510",
"pm_score": 5,
"selected": false,
"text": "<p>I am not quite sure what you need, but I would use something like this:</p>\n\n<pre><code>#!/usr/bin/env ruby\n\n... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35580/"
] | I want to deal with the command line input in Ruby:
```
> cat input.txt | myprog.rb
> myprog.rb < input.txt
> myprog.rb arg1 arg2 arg3 ...
```
What is the best way to do it? In particular I want to deal with blank STDIN, and I hope for an elegant solution.
```
#!/usr/bin/env ruby
STDIN.read.split("\n").each do |a|... | Following are some things I found in my collection of obscure Ruby.
So, in Ruby, a simple no-bells implementation of the Unix command `cat` would be:
```
#!/usr/bin/env ruby
puts ARGF.read
```
[`ARGF`](https://ruby-doc.org/core/ARGF.html) is your friend when it comes to input; it is a virtual file that gets all inp... |
273,275 | <p>Rails has an awesome way of looking up column names and expected datatypes from the DB, alleviating a lot of programming.</p>
<p>I'm trying to build something like this in C#.NET, because we have large tables that are ever changing. I'll be adding parameters like so:</p>
<pre><code>SqlParameter param = new SqlPara... | [
{
"answer_id": 273305,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 2,
"selected": false,
"text": "<p>why not just let ADO.NET detect it automatically:</p>\n\n<pre><code>SqlParameter param = new SqlParameter(\"parametername... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25538/"
] | Rails has an awesome way of looking up column names and expected datatypes from the DB, alleviating a lot of programming.
I'm trying to build something like this in C#.NET, because we have large tables that are ever changing. I'll be adding parameters like so:
```
SqlParameter param = new SqlParameter("parametername"... | why not just let ADO.NET detect it automatically:
```
SqlParameter param = new SqlParameter("parametername", value);
```
'course, you don't actually need Direction, either:
```
comm.Parameters.Add(new SqlParameter("parametername",value));
```
I'm kind of a fan of doing things in one line :) |
273,283 | <p>I just added printing capability to a web site using a style sheet (ie. @media print, etc.) and was wondering if I could use a similar method for adding support for mobile devices.</p>
<p>If not, how do I detect a mobile device? My pages are C# (.aspx) and I'd like to scale back the pages for ease of use on a mobi... | [
{
"answer_id": 273289,
"author": "Rob Allen",
"author_id": 149,
"author_profile": "https://Stackoverflow.com/users/149",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not sure how the IPhone/iPod Touch declare themselves when requesting the stylesheet, but for most, using </p>\n\n<pre... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20848/"
] | I just added printing capability to a web site using a style sheet (ie. @media print, etc.) and was wondering if I could use a similar method for adding support for mobile devices.
If not, how do I detect a mobile device? My pages are C# (.aspx) and I'd like to scale back the pages for ease of use on a mobile device.
... | I'm not sure how the IPhone/iPod Touch declare themselves when requesting the stylesheet, but for most, using
```
<style type="text/css">
@media handheld
{
/* handheld styles */
}
</style>
```
should do the trick. It works in the same way @media print does (or doesn't).
For a complete list of me... |
273,297 | <p>Few of us would deny the awesomeness of debuggers, but to make it more useful, some tricks can be used. </p>
<p>For example in Python, you can use <strong><em>pass</em></strong> to do absolutely nothing except to leave you room to put a break point and allow you to observe the values in the Watch window. </p>
<p>I... | [
{
"answer_id": 273303,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 6,
"selected": true,
"text": "<p>In C#, you can use this:</p>\n\n<pre><code>System.Diagnostics.Debugger.Break();\n</code></pre>\n\n<p>It will force a break... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10088/"
] | Few of us would deny the awesomeness of debuggers, but to make it more useful, some tricks can be used.
For example in Python, you can use ***pass*** to do absolutely nothing except to leave you room to put a break point and allow you to observe the values in the Watch window.
In C#, I used to do ***GC.Collect()***... | In C#, you can use this:
```
System.Diagnostics.Debugger.Break();
```
It will force a breakpoint. |
273,313 | <p>What is the best way to randomize the order of a generic list in C#? I've got a finite set of 75 numbers in a list I would like to assign a random order to, in order to draw them for a lottery type application.</p>
| [
{
"answer_id": 273351,
"author": "dmo",
"author_id": 1807,
"author_profile": "https://Stackoverflow.com/users/1807",
"pm_score": 2,
"selected": false,
"text": "<p>If you have a fixed number (75), you could create an array with 75 elements, then enumerate your list, moving the elements to... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35286/"
] | What is the best way to randomize the order of a generic list in C#? I've got a finite set of 75 numbers in a list I would like to assign a random order to, in order to draw them for a lottery type application. | Shuffle any `(I)List` with an extension method based on the [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher-Yates_shuffle):
```
private static Random rng = new Random();
public static void Shuffle<T>(this IList<T> list)
{
int n = list.Count;
while (n > 1) {
n--;
int k = ... |
273,314 | <p>For example, in <a href="http://homepages.cwi.nl/~paulv/papers/algorithmicstatistics.pdf" rel="noreferrer">http://homepages.cwi.nl/~paulv/papers/algorithmicstatistics.pdf</a> at the bottom of page 5 and top of page 6, he uses a plus/equal symbol and a similar plus/lessthan symbol. I can't figure out how to make tha... | [
{
"answer_id": 273338,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 1,
"selected": false,
"text": "<p>Here's the list of <a href=\"http://web.ift.uib.no/Fysisk/Teori/KURS/WRK/TeX/symALL.html\" rel=\"nofollow norefer... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35600/"
] | For example, in <http://homepages.cwi.nl/~paulv/papers/algorithmicstatistics.pdf> at the bottom of page 5 and top of page 6, he uses a plus/equal symbol and a similar plus/lessthan symbol. I can't figure out how to make that symbol, and I'd like to quote him.
Any help? | Try `$\stackrel{top}{bottom}$`
You'd want something like this:
```
$X \stackrel{+}{=} Y$
```
This positions the plus sign above the equals sign. For example, the following code:
```
$K(x,y|z) \stackrel{+}{=} K(x|z) \stackrel{+}{<} I(x:y|z)$
```
produces the following output:
![Equation including + sign over = s... |
273,353 | <p>Note: The examples below are C# but this problem should not be specific to any language in particular.</p>
<p>So I am building an object domain using a variant of the <a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx" rel="nofollow noreferrer">S# Architecture</a>. For those unfamilia... | [
{
"answer_id": 273390,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 1,
"selected": false,
"text": "<p>The lazy loading should be managed by your persistance layer, not your repositories.</p>\n\n<p>Also your Customer and Prod... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | Note: The examples below are C# but this problem should not be specific to any language in particular.
So I am building an object domain using a variant of the [S# Architecture](http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx). For those unfamiliar with it, and to save you some reading time the... | I just discovered a significantly better approach that works at least with Castle Windsor. By changing the data access object dependencies to properties rather than constructor dependencies Windsor will autofill them after instantiating each object fully.
So the following works just fine:
```
public class CustomerDao... |
273,354 | <p>I am a big time user of using double quotes in PHP so that I can interpolate variables rather than concatenating strings. As a result, when I am generating HTML I often use single quotes for setting tag fields. For example:</p>
<pre><code>$html = "<input type='text' name='address' value='$address'>";
</code><... | [
{
"answer_id": 273366,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 7,
"selected": false,
"text": "<p>This is similar to <a href=\"https://stackoverflow.com/questions/242766/when-did-single-quotes-in-html-become-so-popul... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am a big time user of using double quotes in PHP so that I can interpolate variables rather than concatenating strings. As a result, when I am generating HTML I often use single quotes for setting tag fields. For example:
```
$html = "<input type='text' name='address' value='$address'>";
```
Now this is far more r... | This is similar to [When did single quotes in HTML become so popular?](https://stackoverflow.com/questions/242766/when-did-single-quotes-in-html-become-so-popular). Single quotes around attributes in HTML are and always have been permitted by [the specification](http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2). I... |
273,356 | <p>I have some pages on my site that are plain HTML pages, but I want to add some ASP .NET type functionality to these pages. My concern is that if I simple rename the .html page to .aspx that I will break links, and lose SEO, and so on.</p>
<p>I would think there is a "best practice" for how to handle this situation.... | [
{
"answer_id": 273362,
"author": "vfilby",
"author_id": 24279,
"author_profile": "https://Stackoverflow.com/users/24279",
"pm_score": 0,
"selected": false,
"text": "<p>You could use ISAPI rewrite to redirect the .html urls to the .aspx urls. </p>\n\n<p>The idea here is that you rename al... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23294/"
] | I have some pages on my site that are plain HTML pages, but I want to add some ASP .NET type functionality to these pages. My concern is that if I simple rename the .html page to .aspx that I will break links, and lose SEO, and so on.
I would think there is a "best practice" for how to handle this situation. | Create your new pages on aspx, and just serve 301 permanent redirects from the HTML pages.
Search spiders are smart enough to realize the content has moved and will not penalize you.
Both Google and Yahoo also say that they parse a meta-refresh with no delay as a 301 redirect, so just do something like this:
```
<ht... |
273,374 | <p>So, if i have:</p>
<pre><code>public class Sedan : Car
{
/// ...
}
public class Car : Vehicle, ITurn
{
[MyCustomAttribute(1)]
public int TurningRadius { get; set; }
}
public abstract class Vehicle : ITurn
{
[MyCustomAttribute(2)]
public int TurningRadius { get; set; }
}
public interface ITur... | [
{
"answer_id": 273414,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 2,
"selected": false,
"text": "<pre><code>object[] SomeMagic (PropertyInfo property)\n{\n return property.GetCustomAttributes(true);\n}\n</code></pr... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] | So, if i have:
```
public class Sedan : Car
{
/// ...
}
public class Car : Vehicle, ITurn
{
[MyCustomAttribute(1)]
public int TurningRadius { get; set; }
}
public abstract class Vehicle : ITurn
{
[MyCustomAttribute(2)]
public int TurningRadius { get; set; }
}
public interface ITurn
{
[MyCus... | this is a framework issue. Interface attributes are ignored by GetCustomAttributes. see the comment on this blog post <http://hyperthink.net/blog/getcustomattributes-gotcha/#comment-65> |
273,410 | <p>How can I find out the number of dimensions in an array in Classic ASP ( VBScript ) .</p>
<p>I am being passed an Array with multiple dimensions but I only want to look at the last. Seems easy in other languages.</p>
| [
{
"answer_id": 273454,
"author": "Bullines",
"author_id": 27870,
"author_profile": "https://Stackoverflow.com/users/27870",
"pm_score": 4,
"selected": true,
"text": "<pre><code>Ubound(MySingleDimensionalArray, 2) ' Number of Array Elements\n\nUbound(MyMultiDimensionalArray, 1) ' Number ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | How can I find out the number of dimensions in an array in Classic ASP ( VBScript ) .
I am being passed an Array with multiple dimensions but I only want to look at the last. Seems easy in other languages. | ```
Ubound(MySingleDimensionalArray, 2) ' Number of Array Elements
Ubound(MyMultiDimensionalArray, 1) ' Number of Columns
Ubound(MyMultiDimensionalArray, 2) ' Number of Rows
``` |
273,425 | <p>I have code that lets me select a single item in arange:</p>
<pre><code> COleVariant vItems = cstrAddr;
hr = AutoWrap(
DISPATCH_PROPERTYGET,
&vCell,
irange,
L"Item",
... | [
{
"answer_id": 273426,
"author": "jons911",
"author_id": 34375,
"author_profile": "https://Stackoverflow.com/users/34375",
"pm_score": 2,
"selected": false,
"text": "<p>If you can't install AJAX extensions, you will have to manage the AJAX calls yourself. It's absolutely possible, since... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965047/"
] | I have code that lets me select a single item in arange:
```
COleVariant vItems = cstrAddr;
hr = AutoWrap(
DISPATCH_PROPERTYGET,
&vCell,
irange,
L"Item",
2,
... | You don't need to install the AJAX extensions into the server's GAC.
You can locally reference System.Web.Extensions.dll from your applications BIN folder....I've done it half a dozen times.
Copy that DLL to your projects local bin. Reference it from your project. Remember to deploy the DLL when you deploy, and you a... |
273,433 | <p>I've been Googling around for .htaccess redirection information, but nothing I find is quite what I'm looking for.</p>
<p>Basically, I want a solution that will take a site example.com and allow you to enter URL's like:</p>
<pre><code> 123.example.com
ksdfkjds.example.com
dsf38jif348.example.com
</code></pre>
<... | [
{
"answer_id": 273456,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "<p>Try something like this:</p>\n\n<pre><code># If we're not on http://example.com\nRewriteCond %{HTTP_HOST} .+\\.example.com... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been Googling around for .htaccess redirection information, but nothing I find is quite what I'm looking for.
Basically, I want a solution that will take a site example.com and allow you to enter URL's like:
```
123.example.com
ksdfkjds.example.com
dsf38jif348.example.com
```
and this would redirect them to... | Try something like this:
```
# If we're not on http://example.com
RewriteCond %{HTTP_HOST} .+\.example.com
# Add the host to the front of the URL and chain with the next rule
RewriteRule ^(.*)$ ${HOST}$1 [C,QSA]
# Make the host a directory
RewriteRule ^(.*)\.example\.com(.*)$ http://example.com/$1$2 [QSA]
```
You ... |
273,447 | <p>I am using the .NET 3.5 SP1 framework and I've implemented URL routing in my application. I was getting javascript errors: </p>
<p><code>
Error: ASP.NET Ajax client-side framework failed to load.<br>
Resource interpreted as script but transferred with MIME type text/html.<br>
ReferenceError: Can't find variable: S... | [
{
"answer_id": 273470,
"author": "Dan Esparza",
"author_id": 19020,
"author_profile": "https://Stackoverflow.com/users/19020",
"pm_score": 1,
"selected": false,
"text": "<p>MapRoute and IgnoreRoute are extension methods in System.Web.Mvc --- do you have that assembly referenced properly?... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32854/"
] | I am using the .NET 3.5 SP1 framework and I've implemented URL routing in my application. I was getting javascript errors:
`Error: ASP.NET Ajax client-side framework failed to load.
Resource interpreted as script but transferred with MIME type text/html.
ReferenceError: Can't find variable: Sys`
Which I believ... | You don't need to reference ASP.NET MVC. You can use the [StopRoutingHandler](http://msdn.microsoft.com/en-us/library/system.web.routing.stoproutinghandler.aspx) which implements IRouteHandler like so:
```
routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));
```
This is part of .NET 3.5 SP1... |
273,450 | <p>Has anybody implemented a feature where if the user has not touched the screen for a certain time period, you take a certain action? I'm trying to figure out the best way to do that.</p>
<p>There's this somewhat-related method in UIApplication:</p>
<pre><code>[UIApplication sharedApplication].idleTimerDisabled;
</... | [
{
"answer_id": 273656,
"author": "wisequark",
"author_id": 33159,
"author_profile": "https://Stackoverflow.com/users/33159",
"pm_score": 2,
"selected": false,
"text": "<p>Ultimately you need to define what you consider to be idle - is idle the result of the user not touching the screen o... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/544/"
] | Has anybody implemented a feature where if the user has not touched the screen for a certain time period, you take a certain action? I'm trying to figure out the best way to do that.
There's this somewhat-related method in UIApplication:
```
[UIApplication sharedApplication].idleTimerDisabled;
```
It'd be nice if y... | Here's the answer I had been looking for:
Have your application delegate subclass UIApplication. In the implementation file, override the sendEvent: method like so:
```
- (void)sendEvent:(UIEvent *)event {
[super sendEvent:event];
// Only want to reset the timer on a Began touch or an Ended touch, to reduce ... |
273,452 | <p>I can't seem to find a nice clean example of using AES 128 bit encryption.</p>
<p>Does anyone have some sample code?</p>
| [
{
"answer_id": 273499,
"author": "Dan Esparza",
"author_id": 19020,
"author_profile": "https://Stackoverflow.com/users/19020",
"pm_score": 7,
"selected": false,
"text": "<p>If you just want to use the built-in crypto provider RijndaelManaged, check out the following help article (it also... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I can't seem to find a nice clean example of using AES 128 bit encryption.
Does anyone have some sample code? | If you just want to use the built-in crypto provider RijndaelManaged, check out the following help article (it also has a simple code sample):
>
> <http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx>
>
>
>
And just in case you need the sample in a hurry, here it is in all it... |
273,485 | <p>Seems likes it might be useful to have the assert display a message when an assertion fails.</p>
<p>Currently an <code>AssertionError</code> gets thrown, can you specify a custom message for it?</p>
<p>Can you show an example mechanism for doing this (other than creating your own exception type and throwing it)?</... | [
{
"answer_id": 273488,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": true,
"text": "<p>You certainly can:</p>\n<pre><code>assert x > 0 : "x must be greater than zero, but x = " + x;\n</code></p... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | Seems likes it might be useful to have the assert display a message when an assertion fails.
Currently an `AssertionError` gets thrown, can you specify a custom message for it?
Can you show an example mechanism for doing this (other than creating your own exception type and throwing it)? | You certainly can:
```
assert x > 0 : "x must be greater than zero, but x = " + x;
```
See [Programming with Assertions](https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html) for more information. |
273,487 | <p>I have read the very good blog post of Rob Conery <a href="http://blog.wekeroad.com/blog/crazy-talk-reducing-orm-friction/" rel="nofollow noreferrer">Crazy Talk: Reducing ORM Friction</a><br>
How can I generalize this interface so I can implement it with NHibernate?</p>
<pre><code>using System;
using System.Colle... | [
{
"answer_id": 273503,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 0,
"selected": false,
"text": "<p>You'll need to walk the expression tree and build your Criteria.</p>\n"
},
{
"answer_id": 273506,
"author": "R... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12514/"
] | I have read the very good blog post of Rob Conery [Crazy Talk: Reducing ORM Friction](http://blog.wekeroad.com/blog/crazy-talk-reducing-orm-friction/)
How can I generalize this interface so I can implement it with NHibernate?
```
using System;
using System.Collections;
using System.Linq;
using System.Linq.Exp... | Look at LINQ to NHibernate. Kyle Baley has a great [overview of it](http://codebetter.com/blogs/kyle.baley/archive/2008/04/07/trying-out-linq-for-nhibernate.aspx) |
273,516 | <p>Many of us need to deal with user input, search queries, and situations where the input text can potentially contain profanity or undesirable language. Oftentimes this needs to be filtered out.</p>
<p>Where can one find a good list of swear words in various languages and dialects? </p>
<p>Are there APIs available ... | [
{
"answer_id": 273520,
"author": "HanClinto",
"author_id": 26933,
"author_profile": "https://Stackoverflow.com/users/26933",
"pm_score": 9,
"selected": true,
"text": "<p><a href=\"http://blog.codinghorror.com/obscenity-filters-bad-idea-or-incredibly-intercoursing-bad-idea/\" rel=\"norefe... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27899/"
] | Many of us need to deal with user input, search queries, and situations where the input text can potentially contain profanity or undesirable language. Oftentimes this needs to be filtered out.
Where can one find a good list of swear words in various languages and dialects?
Are there APIs available to sources that c... | [Obscenity Filters: Bad Idea, or Incredibly Intercoursing Bad Idea?](http://blog.codinghorror.com/obscenity-filters-bad-idea-or-incredibly-intercoursing-bad-idea/)
Also, one can't forget [The Untold History of Toontown's SpeedChat](http://habitatchronicles.com/2007/03/the-untold-history-of-toontowns-speedchat-or-block... |
273,530 | <p>Does anybody have a suggestion for a java library that performs automatic cropping and deskewing of images (like those retrieved from a flatbed scanner)?</p>
| [
{
"answer_id": 273552,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.imagemagick.org\" rel=\"nofollow noreferrer\">ImageMagick</a> can do that; you can use the <... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25939/"
] | Does anybody have a suggestion for a java library that performs automatic cropping and deskewing of images (like those retrieved from a flatbed scanner)? | **Deskewing**
Take a look at [Tess4j (Java JNA wrapper for Tesseract)](https://github.com/nguyenq/tess4j).
You can combine [ImageDeskew.getSkewAngle()](http://tess4j.sourceforge.net/docs/docs-2.0/index.html?com/recognition/software/jdeskew/ImageDeskew.html) with [ImageHelper.rotate(BufferedImage image, double angle)... |
273,546 | <p>I'm trying to get a user control working asynchronously, yet no matter what I do it continues to work synchronously. I've stripped it down to its bare minimum as a test web application. This would be the user control:</p>
<pre><code><%@ Control Language="C#" %>
<script runat="server">
SqlConnection ... | [
{
"answer_id": 273717,
"author": "Charles",
"author_id": 24898,
"author_profile": "https://Stackoverflow.com/users/24898",
"pm_score": 4,
"selected": true,
"text": "<p>Looks like I can answer my own question. The user control should not be calling <code>Page.ExecuteRegisteredAsyncTasks</... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24898/"
] | I'm trying to get a user control working asynchronously, yet no matter what I do it continues to work synchronously. I've stripped it down to its bare minimum as a test web application. This would be the user control:
```
<%@ Control Language="C#" %>
<script runat="server">
SqlConnection m_oConnection;
SqlComm... | Looks like I can answer my own question. The user control should not be calling `Page.ExecuteRegisteredAsyncTasks`. By doing that, the control was adding the async task, running it, and waiting for it to complete.
Instead, each instance of the user control should call only `Page.RegisterAsyncTask`. After each control ... |
273,567 | <p>Every Christmas we draw names for gift exchanges in my family. This usually involves mulitple redraws until no one has pulled their spouse. So this year I coded up my own name drawing app that takes in a bunch of names, a bunch of disallowed pairings, and sends off an email to everyone with their chosen giftee.</p... | [
{
"answer_id": 273572,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 3,
"selected": false,
"text": "<p>I wouldn't use disallowed pairings, since that greatly increases the complexity of the problem. Just enter every... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8701/"
] | Every Christmas we draw names for gift exchanges in my family. This usually involves mulitple redraws until no one has pulled their spouse. So this year I coded up my own name drawing app that takes in a bunch of names, a bunch of disallowed pairings, and sends off an email to everyone with their chosen giftee.
Right ... | Just make a graph with edges connecting two people if they are allowed to share gifts and then use a perfect matching algorithm. (Look for "Paths, Trees, and Flowers" for the (clever) algorithm) |
273,578 | <p><a href="https://web.archive.org/web/20210126032647/http://geekswithblogs.net/michelotti/archive/2007/12/17/117791.aspx" rel="nofollow noreferrer">Link</a></p>
<p>I'm using ASP.NET with C# and trying to use linq to sql to update a data context as exhibited on the blog linked above. I created the timestamp field in ... | [
{
"answer_id": 273590,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": true,
"text": "<p>If you have a timestamp column, then to update a record (from a vanilla object): yes, I would expect to have to ass... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35617/"
] | [Link](https://web.archive.org/web/20210126032647/http://geekswithblogs.net/michelotti/archive/2007/12/17/117791.aspx)
I'm using ASP.NET with C# and trying to use linq to sql to update a data context as exhibited on the blog linked above. I created the timestamp field in the table just as stated and am using the follo... | If you have a timestamp column, then to update a record (from a vanilla object): yes, I would expect to have to assign it. Otherwise, you lose the ability to use the timestamp for optimistic concurrency checking.
The idea is you take a copy of the timestamp when you get hold of your (disconnected) object, then when yo... |
273,606 | <p>I am designing a WCF service which a client will call to get a list of GUID's from a server.</p>
<p>How should I define my endpoint contract?</p>
<p>Should I just return an Array? </p>
<p>If so, will the array just be serialized by WCF?</p>
| [
{
"answer_id": 273616,
"author": "Adron",
"author_id": 29345,
"author_profile": "https://Stackoverflow.com/users/29345",
"pm_score": 2,
"selected": false,
"text": "<p>The Guids, if you're going for SOA oriented services, will need to be set as strings. The client will be responsible for ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am designing a WCF service which a client will call to get a list of GUID's from a server.
How should I define my endpoint contract?
Should I just return an Array?
If so, will the array just be serialized by WCF? | The Guids, if you're going for SOA oriented services, will need to be set as strings. The client will be responsible for turning them back into whatever. As for the listing of the Guids, they'd be returned as an array. If you have a contract with a regular Generics List Object of Guids like this
```
[DataMember] List<... |
273,612 | <p>It's a really basic question but i can't think at the second. How do i set up a loop that asks each time the function inside runs whether to do it again. So it runs it then says something like;</p>
<p>"loop again? y/n"</p>
| [
{
"answer_id": 273618,
"author": "Martin Cote",
"author_id": 9936,
"author_profile": "https://Stackoverflow.com/users/9936",
"pm_score": 5,
"selected": true,
"text": "<pre><code>while True:\n func()\n answer = raw_input( \"Loop again? \" )\n if answer != 'y':\n break\n</c... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] | It's a really basic question but i can't think at the second. How do i set up a loop that asks each time the function inside runs whether to do it again. So it runs it then says something like;
"loop again? y/n" | ```
while True:
func()
answer = raw_input( "Loop again? " )
if answer != 'y':
break
``` |
273,623 | <p>I have a list of numbers, say {2,4,5,6,7}
I have a table, foos, with foos.ID, including say, {1,2,3,4,8,9}</p>
<p>Id like to take my list of numbers, and find those without a counterpart in the ID field of my table.</p>
<p>One way to achieve this would be to create a table bars, loaded with {2,4,5,6,7} in the ID f... | [
{
"answer_id": 273649,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 4,
"selected": false,
"text": "<p>I can't find a solution to your precise problem that doesn't use a temporary table, but an alternate way of doing your qu... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26001/"
] | I have a list of numbers, say {2,4,5,6,7}
I have a table, foos, with foos.ID, including say, {1,2,3,4,8,9}
Id like to take my list of numbers, and find those without a counterpart in the ID field of my table.
One way to achieve this would be to create a table bars, loaded with {2,4,5,6,7} in the ID field.
Then, I wou... | This is a problem that is pretty common: generating a relation on the fly without creating a table. SQL solutions for this problem are pretty awkward. One example using a derived table:
```
SELECT n.id
FROM
(SELECT 2 AS id
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7... |
273,624 | <p>How do you create a 1 bit per pixel mask from an image using GDI in C#? The image I am trying to create the mask from is held in a System.Drawing.Graphics object.</p>
<p>I have seen examples that use Get/SetPixel in a loop, which are too slow. The method that interests me is one that uses only BitBlits, like <a hr... | [
{
"answer_id": 273686,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 3,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>using System.Drawing;\nusing System.Drawing.Imaging;\nusing System.Runtime.InteropServ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24201/"
] | How do you create a 1 bit per pixel mask from an image using GDI in C#? The image I am trying to create the mask from is held in a System.Drawing.Graphics object.
I have seen examples that use Get/SetPixel in a loop, which are too slow. The method that interests me is one that uses only BitBlits, like [this](http://ww... | Try this:
```
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
```
...
```
public static Bitmap BitmapTo1Bpp(Bitmap img) {
int w = img.Width;
int h = img.Height;
Bitmap bmp = new Bitmap(w, h, PixelFormat.Format1bppIndexed);
BitmapData data = bmp.Lo... |
273,630 | <p>Actually my question is all in the title.<br>
Anyway:<br>
I have a class and I use explicit constructor:
<br>.h<br></p>
<pre><code>class MyClass
{
public:
explicit MyClass(const string& s): query(s) {}
private:
string query;
}
</code></pre>
<p>Is it obligatory or not to put <b>explicit</b> keyword i... | [
{
"answer_id": 273633,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": true,
"text": "<p>No, it is not. The <code>explicit</code> keyword is only permitted in the header. My gcc says:</p>\n\n<pre><code>test.c... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28298/"
] | Actually my question is all in the title.
Anyway:
I have a class and I use explicit constructor:
.h
```
class MyClass
{
public:
explicit MyClass(const string& s): query(s) {}
private:
string query;
}
```
Is it obligatory or not to put **explicit** keyword in implementation(.cpp) file? | No, it is not. The `explicit` keyword is only permitted in the header. My gcc says:
```
test.cpp:6: error: only declarations of constructors can be 'explicit'
```
for the following code:
```
class foo {
public:
explicit foo(int);
};
explicit foo::foo(int) {}
``` |
273,639 | <p>I have a windows form application that uses a Shared class to house all of the common objects for the application. The settings class has a collection of objects that do things periodically, and then there's something of interest, they need to alert the main form and have it update.</p>
<p>I'm currently doing this ... | [
{
"answer_id": 273653,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 3,
"selected": true,
"text": "<p>I think it is a threading problem too. Are you using Control.Invoke() in your event handler? .NET usually catches... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8114/"
] | I have a windows form application that uses a Shared class to house all of the common objects for the application. The settings class has a collection of objects that do things periodically, and then there's something of interest, they need to alert the main form and have it update.
I'm currently doing this through Ev... | I think it is a threading problem too. Are you using Control.Invoke() in your event handler? .NET usually catches violations when you debug the app but there are cases it can't. NotifyIcon is one of them, there is no window handle to check thread affinity.
Edit after OP changed question:
A classic VB.NET trap is to r... |
273,641 | <p>This question has been discussed in two blog posts (<a href="http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/" rel="nofollow noreferrer">http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/</a>, <a href="http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking... | [
{
"answer_id": 273690,
"author": "jiriki",
"author_id": 19907,
"author_profile": "https://Stackoverflow.com/users/19907",
"pm_score": 1,
"selected": false,
"text": "<p>Well, I don't think it is.</p>\n\n<p>The first if-statement: </p>\n\n<pre><code>if (counter == HeartBeatThread.counter) ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20022/"
] | This question has been discussed in two blog posts (<http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/>, <http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/>), but I haven't heard a definitive answer yet. If we have one thread that does this:
```
public c... | Within the java memory model? No, you are not ok.
I've seen a number of attempts to head towards a very 'soft flush' approach like this, but without an explicit fence, you're definitely playing with fire.
The 'happens before' semantics in
<http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.7>
st... |
273,662 | <p>With multiple developers working on the same Tomcat application, I'd like to tell the application to install to a different path, based on the current user and revision control client/view.</p>
<p>So, if Bob is building, the app should be installed in Bob's test environment, maybe /bob1 or something like that. Bob... | [
{
"answer_id": 275622,
"author": "flicken",
"author_id": 12880,
"author_profile": "https://Stackoverflow.com/users/12880",
"pm_score": 2,
"selected": false,
"text": "<p>You can override ant properties from the command line. </p>\n\n<pre><code>ant -Dinstall.location=/bob1 install\n</code... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22917/"
] | With multiple developers working on the same Tomcat application, I'd like to tell the application to install to a different path, based on the current user and revision control client/view.
So, if Bob is building, the app should be installed in Bob's test environment, maybe /bob1 or something like that. Bob might have... | I typically use a variation on the default properties answer already given:
```
<property file="local.properties" />
<property file="default.properties" />
```
I read the local properties file first and the default one second. Users don't edit the default one (then accidentally check it in), they just define the pro... |
273,664 | <p>I find AWK really useful. Here is a one liner I put together to manipulate data.</p>
<pre><code>ls | awk '{ print "awk " "'"'"'" " {print $1,$2,$3} " "'"'"'" " " $1 ".old_ext > " $1 ".new_ext" }' > file.csh
</code></pre>
<p>I used this AWK to make a script file that would rename some files and only pr... | [
{
"answer_id": 273673,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 1,
"selected": false,
"text": "<p>Henry Spencer wrote a fairly good implementation of nroff on awk. He called it \"awf\". He also claimed that if La... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30181/"
] | I find AWK really useful. Here is a one liner I put together to manipulate data.
```
ls | awk '{ print "awk " "'"'"'" " {print $1,$2,$3} " "'"'"'" " " $1 ".old_ext > " $1 ".new_ext" }' > file.csh
```
I used this AWK to make a script file that would rename some files and only print out selective columns. Anyone... | The [AWK book](https://archive.org/details/pdfy-MgN0H1joIoDVoIC7) is full of great examples. They used to be collected for download from [Kernighan's webpage](http://cm.bell-labs.com/cm/cs/who/bwk/awkcode.txt) (404s now). |
273,671 | <p>In an attempt to hide the Safari UI components for an web-app bookmarked as a Homescreen Icon. I am using this meta tag </p>
<pre><code><meta name="apple-mobile-web-app-capable" content="yes" />
</code></pre>
<p>as specified on <a href="https://developer.apple.com/library/content/documentation/AppleApplicati... | [
{
"answer_id": 273693,
"author": "crashmstr",
"author_id": 1441,
"author_profile": "https://Stackoverflow.com/users/1441",
"pm_score": 3,
"selected": false,
"text": "<p>Is it being launched from the home screen? The documentation on the linked page does not mention but I found this @ <a ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In an attempt to hide the Safari UI components for an web-app bookmarked as a Homescreen Icon. I am using this meta tag
```
<meta name="apple-mobile-web-app-capable" content="yes" />
```
as specified on [iPhone Dev Center](https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariW... | ```
window.top.scrollTo(0, 1);
```
Works on iPhone, but not in iPad. I have been successful hiding the browser components on iPad (so presumably everywhere) by using
```
<meta name="apple-mobile-web-app-capable" content="yes" />
```
and launching from a home-screen link. I am also using
```
<meta name="viewport" ... |
273,675 | <p>From an application I'm building I need to print existing PDFs (created by another app).
How can I do this in C# and provide a mechanism so the user can select a different printer or other properties. </p>
<p>I've looked at the PrintDialog but not sure what file it is attempting to print, if any, b/c the output is... | [
{
"answer_id": 273702,
"author": "plinth",
"author_id": 20481,
"author_profile": "https://Stackoverflow.com/users/20481",
"pm_score": 1,
"selected": false,
"text": "<p>You will need Acrobat or some other application that can print the PDF. From there you P/Invoke to <a href=\"http://msd... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | From an application I'm building I need to print existing PDFs (created by another app).
How can I do this in C# and provide a mechanism so the user can select a different printer or other properties.
I've looked at the PrintDialog but not sure what file it is attempting to print, if any, b/c the output is always a ... | Display a little dialog with a combobox that has its Items set to the string collection returned by `PrinterSettings.InstalledPrinters`.
If you can make it a requirement that [GSView](http://pages.cs.wisc.edu/~ghost/gsview/gsprint.htm) be installed on the machine, you can then silently print the PDF. It's a little slo... |
273,695 | <p>I've been using a local git repository interacting with my group's CVS repository for several months, now. I've made an almost neurotic number of branches, most of which have thankfully merged back into my trunk. But naming is starting to become an issue. If I have a task easily named with a simple label, but I a... | [
{
"answer_id": 273760,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 6,
"selected": false,
"text": "<p>My personal preference is to delete the branch name after I’m done with a topic branch.</p>\n\n<p>Instead of ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] | I've been using a local git repository interacting with my group's CVS repository for several months, now. I've made an almost neurotic number of branches, most of which have thankfully merged back into my trunk. But naming is starting to become an issue. If I have a task easily named with a simple label, but I accompl... | Here are some branch naming conventions that I use and the reasons for them
**Branch naming conventions**
1. Use grouping tokens (words) at the beginning of your branch names.
2. Define and use short lead tokens to differentiate branches in a way that is meaningful to your workflow.
3. Use slashes to separate parts o... |
273,711 | <p>I have an Eclipse RCP application that displays a lot (10k+) of small images next to each other, like a film strip. For each image, I am using a SWT <code>Image</code> object. This uses an excessive amount of memory and resources. I am looking for a more efficient way. I thought of taking all of these images and... | [
{
"answer_id": 287468,
"author": "alexmcchessers",
"author_id": 998,
"author_profile": "https://Stackoverflow.com/users/998",
"pm_score": 0,
"selected": false,
"text": "<p>Presumably not every image is visible on screen at any one time? Perhaps a better solution would be to only load th... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/725/"
] | I have an Eclipse RCP application that displays a lot (10k+) of small images next to each other, like a film strip. For each image, I am using a SWT `Image` object. This uses an excessive amount of memory and resources. I am looking for a more efficient way. I thought of taking all of these images and concatenating the... | You can draw directly on the GC (graphics context) of a new (big) image. Having one big Image should result in much less resource usage than thousands of smaller images (each image in SWT keeps some OS graphics object handle)
What you can try is something like this:
```
final List<Image> images;
final... |
273,721 | <p>I wonder if there is an example which html files and java files are resides in different folders. </p>
| [
{
"answer_id": 273818,
"author": "Loren_",
"author_id": 13703,
"author_profile": "https://Stackoverflow.com/users/13703",
"pm_score": 3,
"selected": false,
"text": "<p>I don't recommend using a separate page directory unless you are quite comfortable with how resource streams work, which... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34367/"
] | I wonder if there is an example which html files and java files are resides in different folders. | I don't recommend using a separate page directory unless you are quite comfortable with how resource streams work, which I am not.
The vast majority of wicket projects I have seen keep class and html files in the source directory. I tried separating them myself but then found that getting my hands on other resources, ... |
273,732 | <p>I have an application where, in the course of using the application, a user might click from</p>
<pre><code>virginia.usa.com
</code></pre>
<p>to</p>
<pre><code>newyork.usa.com
</code></pre>
<p>Since I'd rather not create a new session each time a user crosses from one subdomain to another, what's a good way to s... | [
{
"answer_id": 273761,
"author": "Robert Elwell",
"author_id": 23102,
"author_profile": "https://Stackoverflow.com/users/23102",
"pm_score": 0,
"selected": false,
"text": "<p>If you're using PHP, one hack would be to make a little include script (or two) to do the following:</p>\n\n<p>1 ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28118/"
] | I have an application where, in the course of using the application, a user might click from
```
virginia.usa.com
```
to
```
newyork.usa.com
```
Since I'd rather not create a new session each time a user crosses from one subdomain to another, what's a good way to share session info across multiple subdomains? | You tagged this with ASP.NET and IIS, so I will assume that is your environment. Make sure you have this in your web.config:
```
<httpCookies domain=".usa.com"/>
```
If your 2 subdomains map to the same application, then you are done. However, if they are different applications you will need to do some additional wo... |
273,743 | <p>I have a web directory where I store some config files. I'd like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like:</p>
<pre><code>http://mysite.com/configs/.vim/
</code></pre>
<p>.vim holds multiple files and directories. I want to replicate t... | [
{
"answer_id": 273755,
"author": "Conor McDermottroe",
"author_id": 63985,
"author_profile": "https://Stackoverflow.com/users/63985",
"pm_score": 3,
"selected": false,
"text": "<pre><code>wget -r http://mysite.com/configs/.vim/\n</code></pre>\n\n<p>works for me.</p>\n\n<p>Perhaps you hav... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476/"
] | I have a web directory where I store some config files. I'd like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like:
```
http://mysite.com/configs/.vim/
```
.vim holds multiple files and directories. I want to replicate that on the client using wg... | You have to pass the `-np`/`--no-parent` option to `wget` (in addition to `-r`/`--recursive`, of course), otherwise it will follow the link in the directory index on my site to the parent directory. So the command would look like this:
```
wget --recursive --no-parent http://example.com/configs/.vim/
```
To avoid do... |
273,751 | <p>I have a SSIS package that eventually I would like to pass parameters too, these parameters will come from a .NET application (VB or C#) so I was curious if anyone knows of how to do this, or better yet a website with helpful hints on how to do it. </p>
<p>So basically I want to execute a SSIS package from .NET pas... | [
{
"answer_id": 1920083,
"author": "Craig Schwarze",
"author_id": 226235,
"author_profile": "https://Stackoverflow.com/users/226235",
"pm_score": 6,
"selected": false,
"text": "<p>Here is how to set variables in the package from code - </p>\n\n<pre><code>using Microsoft.SqlServer.Dts.Runt... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a SSIS package that eventually I would like to pass parameters too, these parameters will come from a .NET application (VB or C#) so I was curious if anyone knows of how to do this, or better yet a website with helpful hints on how to do it.
So basically I want to execute a SSIS package from .NET passing the S... | Here is how to set variables in the package from code -
```
using Microsoft.SqlServer.Dts.Runtime;
private void Execute_Package()
{
string pkgLocation = @"c:\test.dtsx";
Package pkg;
Application app;
DTSExecResult pkgResults;
Variables vars;
app = new ... |
273,789 | <p>In javascript, is there an equivalent of String.indexOf() that takes a regular expression instead of a string for the first first parameter while still allowing a second parameter ?</p>
<p>I need to do something like </p>
<pre><code>str.indexOf(/[abc]/ , i);
</code></pre>
<p>and</p>
<pre><code>str.lastIndexOf(/[... | [
{
"answer_id": 273797,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 3,
"selected": false,
"text": "<p>You could use substr.</p>\n\n<pre><code>str.substr(i).match(/[abc]/);\n</code></pre>\n"
},
{
"answer_id": 27... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/238/"
] | In javascript, is there an equivalent of String.indexOf() that takes a regular expression instead of a string for the first first parameter while still allowing a second parameter ?
I need to do something like
```
str.indexOf(/[abc]/ , i);
```
and
```
str.lastIndexOf(/[abc]/ , i);
```
While String.search() take... | Combining a few of the approaches already mentioned (the indexOf is obviously rather simple), I think these are the functions that will do the trick:
```
function regexIndexOf(string, regex, startpos) {
var indexOf = string.substring(startpos || 0).search(regex);
return (indexOf >= 0) ? (indexOf + (startpos ||... |
273,794 | <p>Similar to <a href="https://stackoverflow.com/questions/85978/query-a-tables-foreign-key-relationships">this question</a> but for MySQL....</p>
<p>How can I programmatically determine foreign key references in MySQL (assuming InnoDB)? I can almost get them with:</p>
<pre><code>SHOW TABLE STATUS WHERE Name = 'MyTa... | [
{
"answer_id": 273812,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "<p>Try <code>INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS</code></p>\n"
},
{
"answer_id": 273907,
"author": "B... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23934/"
] | Similar to [this question](https://stackoverflow.com/questions/85978/query-a-tables-foreign-key-relationships) but for MySQL....
How can I programmatically determine foreign key references in MySQL (assuming InnoDB)? I can almost get them with:
```
SHOW TABLE STATUS WHERE Name = 'MyTableName';
```
...but alas, the ... | There are two tables you can query to get this information: [`INFORMATION_SCHEMA.TABLE_CONSTRAINTS`](http://dev.mysql.com/doc/refman/5.1/en/table-constraints-table.html) and [`INFORMATION_SCHEMA.KEY_COLUMN_USAGE`](http://dev.mysql.com/doc/refman/5.1/en/key-column-usage-table.html).
Here's a query from the comments on ... |
273,803 | <p>How can I figure out what is actually causing the following error? The page is the same as other pages but for some reason, only this page is having this error. It also only happens on the ISP (GoDaddy) who has a trust level of Medium and I can't set a breakpoint and try to catch it.</p>
<pre><code>Server Error in ... | [
{
"answer_id": 273851,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 1,
"selected": false,
"text": "<p>I don't believe GoDaddy supports Full trust - though that may have changed recently. The error is caused by the <a ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] | How can I figure out what is actually causing the following error? The page is the same as other pages but for some reason, only this page is having this error. It also only happens on the ISP (GoDaddy) who has a trust level of Medium and I can't set a breakpoint and try to catch it.
```
Server Error in '/' Applicatio... | Have you tried using a local instance of IIS and setting the trust level to medium? That would help you debug and try stuff a little quicker.
(And is a good habit to get into anyway. You want to test in an environment as close to production as possible. And the VS web server definitely has a few important differences... |
273,809 | <p>I have a bunch of controls on my window. One of them is a refresh button that performs a cumbersome task on a background thread.</p>
<p>When the user clicks the refresh button, I put the cursor in a wait (hourglass) status and disable the whole window -- <code>Me.IsEnabled = False</code>.</p>
<p>I'd like to suppo... | [
{
"answer_id": 273846,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 2,
"selected": false,
"text": "<p>You can data bind each controls IsEnabled property to your custom boolean dependency property that signals when you... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132931/"
] | I have a bunch of controls on my window. One of them is a refresh button that performs a cumbersome task on a background thread.
When the user clicks the refresh button, I put the cursor in a wait (hourglass) status and disable the whole window -- `Me.IsEnabled = False`.
I'd like to support cancellation of the refres... | You can put all the controls in one panel (Grid, StackPanel, etc.), and leave the cancel button in another panel. Then set the IsEnabled property of the other panel.
In practice, this will probably introduce more than one additional panel.
For example, if you had a StackPanel of buttons, you can add an additional Sta... |
273,847 | <p>I'm developing multi-language support for our web app. We're using <a href="http://docs.djangoproject.com/en/dev/topics/i18n/" rel="noreferrer">Django's helpers</a> around the <a href="http://en.wikipedia.org/wiki/Gettext" rel="noreferrer">gettext</a> library. Everything has been surprisingly easy, except for the qu... | [
{
"answer_id": 273914,
"author": "hangy",
"author_id": 11963,
"author_profile": "https://Stackoverflow.com/users/11963",
"pm_score": 3,
"selected": false,
"text": "<p>Disclaimer: I am not experienced in internationalization of software myself.</p>\n\n<ol>\n<li>I don't think this would be... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm developing multi-language support for our web app. We're using [Django's helpers](http://docs.djangoproject.com/en/dev/topics/i18n/) around the [gettext](http://en.wikipedia.org/wiki/Gettext) library. Everything has been surprisingly easy, except for the question of how to handle sentences that include significant ... | 2, with a potential twist.
You certainly could localize the whole string, like:
```
loginLink=Please <a href="/login">log in</a> to continue
```
However, depending on your tooling and your localization group, they might prefer for you to do something like:
```
// tokens in this string add html links
loginLink=Plea... |
273,848 | <p>I am developing a HTML form designer that needs to generate static HTML and show this to the user. I keep writing ugly code like this:</p>
<pre><code>public string GetCheckboxHtml()
{
return ("&lt;input type="checkbox" name="somename" /&gt;");
}
</code></pre>
<p>Isn't there a set of strongly typed clas... | [
{
"answer_id": 273866,
"author": "Jacob Carpenter",
"author_id": 26627,
"author_profile": "https://Stackoverflow.com/users/26627",
"pm_score": 2,
"selected": false,
"text": "<p>One option is to use <a href=\"http://msdn.microsoft.com/en-us/library/system.xml.linq.xelement.aspx\" rel=\"no... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am developing a HTML form designer that needs to generate static HTML and show this to the user. I keep writing ugly code like this:
```
public string GetCheckboxHtml()
{
return ("<input type="checkbox" name="somename" />");
}
```
Isn't there a set of strongly typed classes that describe html elements an... | Well, if you download the [ASP.NET MVC](http://www.codeplex.com/aspnet/Wiki/View.aspx?title=MVC&referringTitle=Home) DLL's (which you can use in *any* type of project... including Console apps)... then you can use the many HTML helpers they have. |
273,869 | <p>The topic generically says it all. Basically in a situation like this:</p>
<pre><code>boost::scoped_array<int> p(new int[10]);
</code></pre>
<p>Is there any appreciable difference in performance between doing: <code>&p[0]</code> and <code>p.get()</code>?</p>
<p>I ask because I prefer the first one, it h... | [
{
"answer_id": 273900,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 2,
"selected": false,
"text": "<p>The only way to know is to actually measure it!</p>\n\n<p>But if you have the source of the boost:scoped_array you ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13430/"
] | The topic generically says it all. Basically in a situation like this:
```
boost::scoped_array<int> p(new int[10]);
```
Is there any appreciable difference in performance between doing: `&p[0]` and `p.get()`?
I ask because I prefer the first one, it has a more natural pointer like syntax. In fact, it makes it so yo... | OK, I've done some basic tests as per Martin York's suggestions.
It seems that g++ (4.3.2) is actually pretty good about this. At both -O2 and -O3 optimization levels, it outputs slightly different but functionally equivalent assembly for both `&p[0]` and `p.get()`.
At -Os as expected, it took the path of least compl... |
273,898 | <p>I have two forms in microsoft access, one called Bill and the other one called Payment. They both have Total amount as a field in both of the forms. I am trying to reference the Bill total amount to the Payment total amount. </p>
<p>I have tried in the Payment total amount control source : =Forms!Bill![Total Amount... | [
{
"answer_id": 273950,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 2,
"selected": false,
"text": "<p>Is either of the forms a subform? If so, you need to reference the subform control or the parent property:</p>\n\n<pre>... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have two forms in microsoft access, one called Bill and the other one called Payment. They both have Total amount as a field in both of the forms. I am trying to reference the Bill total amount to the Payment total amount.
I have tried in the Payment total amount control source : =Forms!Bill![Total Amount]
but thi... | Is either of the forms a subform? If so, you need to reference the subform control or the parent property:
```
Me.Parent.[Total order]
Me.[Subform Control name Here].form.[Total order]
```
Note that the Subform Control name is not always the same as the form contained.
EDIT: Either omit Me or use Form!FormName in a... |
273,908 | <p>Problem: I have an integer; this integer needs to be converted to a stl::string type. </p>
<p>In the past, I've used <code>stringstream</code> to do a conversion, and that's just kind of cumbersome. I know the C way is to do a <code>sprintf</code>, but I'd much rather do a C++ method that is typesafe(er).</p>
<p>I... | [
{
"answer_id": 273919,
"author": "David Thornley",
"author_id": 14148,
"author_profile": "https://Stackoverflow.com/users/14148",
"pm_score": 5,
"selected": false,
"text": "<p>Not really, in the standard. Some implementations have a nonstandard itoa() function, and you could look up Boo... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26227/"
] | Problem: I have an integer; this integer needs to be converted to a stl::string type.
In the past, I've used `stringstream` to do a conversion, and that's just kind of cumbersome. I know the C way is to do a `sprintf`, but I'd much rather do a C++ method that is typesafe(er).
Is there a better way to do this?
Here... | Now in c++11 we have
```
#include <string>
string s = std::to_string(123);
```
Link to reference: <http://en.cppreference.com/w/cpp/string/basic_string/to_string> |
273,909 | <p>Is there a idiomatic way of removing elements from PATH-like shell variables?</p>
<p>That is I want to take</p>
<pre><code>PATH=/home/joe/bin:/usr/local/bin:/usr/bin:/bin:/path/to/app/bin:.
</code></pre>
<p>and <strong>remove</strong> or <strong>replace</strong> the <code>/path/to/app/bin</code> without clobberin... | [
{
"answer_id": 273998,
"author": "florin",
"author_id": 18308,
"author_profile": "https://Stackoverflow.com/users/18308",
"pm_score": 2,
"selected": false,
"text": "<p>For deleting an element you can use sed:</p>\n\n<pre><code>#!/bin/bash\nNEW_PATH=$(echo -n $PATH | tr \":\" \"\\n\" | se... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2509/"
] | Is there a idiomatic way of removing elements from PATH-like shell variables?
That is I want to take
```
PATH=/home/joe/bin:/usr/local/bin:/usr/bin:/bin:/path/to/app/bin:.
```
and **remove** or **replace** the `/path/to/app/bin` without clobbering the rest of the variable. Extra points for allowing me *put* new ele... | Addressing the proposed solution from dmckee:
1. While some versions of Bash may allow hyphens in function names, others (MacOS X) do not.
2. I don't see a need to use return immediately before the end of the function.
3. I don't see the need for all the semi-colons.
4. I don't see why you have path-element-by-pattern... |
273,929 | <p><strong>In Oracle I can declare a reference cursor...</strong></p>
<pre><code>TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE;
</code></pre>
<p><strong>...and use it to pass a cursor as the return value...</strong></p>
<pre><code>FUNCTION end_spool
RETURN t_spool
AS
v_spool t_spool;
BEGIN
... | [
{
"answer_id": 274399,
"author": "Spencer Kormos",
"author_id": 8528,
"author_profile": "https://Stackoverflow.com/users/8528",
"pm_score": 2,
"selected": false,
"text": "<p>Googling on cursors in MySQL, it doesn't seem like you can actually return a Cursor from a Proc or Function. Addi... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13930/"
] | **In Oracle I can declare a reference cursor...**
```
TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE;
```
**...and use it to pass a cursor as the return value...**
```
FUNCTION end_spool
RETURN t_spool
AS
v_spool t_spool;
BEGIN
COMMIT;
OPEN v_spool FOR
SELECT
... | Mysql has an implicit cursor that you can magically return from a stored procedure if you issue a select.
Here's an example:
```
CREATE PROCEDURE `TEST`()
MODIFIES SQL DATA
BEGIN
SELECT * FROM test_table;
END;
```
and in your java code:
```
String query = "{CALL TEST()}";
CallableStatement cs = con.prepareCall(q... |
273,937 | <p>I am trying to learn Python and WxPython. I have been a SAS programmer for years. This OOP stuff is slowly coming together but I am still fuzzy on a lot of the concepts. Below is a section of code. I am trying to use a button click to create an instance of another class. Specifically-I have my main panel in one... | [
{
"answer_id": 274004,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know wxWidgets, but based on what I know of Python, I'm guessing that you need to change:</p>\n\n<pre><code>... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30105/"
] | I am trying to learn Python and WxPython. I have been a SAS programmer for years. This OOP stuff is slowly coming together but I am still fuzzy on a lot of the concepts. Below is a section of code. I am trying to use a button click to create an instance of another class. Specifically-I have my main panel in one class a... | You need an event handler in your bind expression
```
self.bind(wx.EVT_MENU, subPanel(None, -1, 'TEST'),id=1)
```
needs to be changed to:
```
self.bind(wx.EVT_MENU, <event handler>, <id of menu item>)
```
where your event handler responds to the event and instantiates the subpanel:
```
def OnMenuItem(self, evt):... |
273,941 | <p>I am trying to write a function that will pull the name of a property and the type using syntax like below:</p>
<pre><code>private class SomeClass
{
Public string Col1;
}
PropertyMapper<Somewhere> propertyMapper = new PropertyMapper<Somewhere>();
propertyMapper.MapProperty(x => x.Col1)
</code></... | [
{
"answer_id": 273971,
"author": "Jacob Carpenter",
"author_id": 26627,
"author_profile": "https://Stackoverflow.com/users/26627",
"pm_score": 7,
"selected": true,
"text": "<p>Here's enough of an example of using <a href=\"http://msdn.microsoft.com/en-us/library/system.linq.expressions.a... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1213936/"
] | I am trying to write a function that will pull the name of a property and the type using syntax like below:
```
private class SomeClass
{
Public string Col1;
}
PropertyMapper<Somewhere> propertyMapper = new PropertyMapper<Somewhere>();
propertyMapper.MapProperty(x => x.Col1)
```
Is there any way to pass the pro... | Here's enough of an example of using [Expressions](http://msdn.microsoft.com/en-us/library/system.linq.expressions.aspx) to get the name of a property or field to get you started:
```
public static MemberInfo GetMemberInfo<T, U>(Expression<Func<T, U>> expression)
{
var member = expression.Body as MemberExpression;... |
273,943 | <p>Presuming I have a class named <code>A</code>, and I want to use the decorator design pattern. Correct me if I'm wrong, but for that to work , we'll need to create a decorator class, say <code>ADecorator</code>, which will hold a reference to an <code>A</code> instance, and all the other decorators will extend this ... | [
{
"answer_id": 274061,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 2,
"selected": false,
"text": "<p>In some languages (like Ruby or JavaScript) you could just add new functionality to an A instance. I notice that yo... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | Presuming I have a class named `A`, and I want to use the decorator design pattern. Correct me if I'm wrong, but for that to work , we'll need to create a decorator class, say `ADecorator`, which will hold a reference to an `A` instance, and all the other decorators will extend this to add functionality.
I don't under... | The decorator pattern is used to add capabilities to objects dynamically (that is, at run time). Normally the object will have its capabilities fixed when you write the class. But an important point is that the functionality of the object is extended in a way that is transparent to the client of the object because it i... |
273,946 | <p>Is there an obvious way to do this that I'm missing? I'm just trying to make thumbnails.</p>
| [
{
"answer_id": 273962,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": 10,
"selected": true,
"text": "<p>Define a maximum size.\nThen, compute a resize ratio by taking <code>min(maxwidth/width, maxheight/height)</code>.</p>\n<p... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3912/"
] | Is there an obvious way to do this that I'm missing? I'm just trying to make thumbnails. | Define a maximum size.
Then, compute a resize ratio by taking `min(maxwidth/width, maxheight/height)`.
The proper size is `oldsize*ratio`.
There is of course also a library method to do this: the method `Image.thumbnail`.
Below is an (edited) example from the [PIL documentation](https://pillow.readthedocs.io/en/st... |
273,949 | <p>For some reason I'm not getting this. (Example model below) If I write: </p>
<pre><code>var property = typeof(sedan).GetProperty("TurningRadius");
Attribute.GetCustomAttributes(property,typeof(MyAttribute), false)
</code></pre>
<p>the call will return MyAttribute(2) despite indicating I don't want to search the in... | [
{
"answer_id": 274005,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>I think this is what you're after - note that I had to make TurningRadius abstract in Vehicle and overridden in Car. ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] | For some reason I'm not getting this. (Example model below) If I write:
```
var property = typeof(sedan).GetProperty("TurningRadius");
Attribute.GetCustomAttributes(property,typeof(MyAttribute), false)
```
the call will return MyAttribute(2) despite indicating I don't want to search the inheritance chain. Does anyo... | Okay, given the extra information - I believe the problem is that `GetProperty` is going up the inheritance change.
If you change your call to `GetProperty` to:
```
PropertyInfo prop = type.GetProperty("TurningRadius",
BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
```
then `prop` wil... |
273,964 | <p>I have a CSS rule like this:</p>
<pre><code>a:hover { background-color: #fff; }
</code></pre>
<p>But this results in a bad-looking gap at the bottom on image links, and what's even worse, if I have transparent images, the link's background color can be seen through the image.</p>
<p>I have stumbled upon this prob... | [
{
"answer_id": 273973,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "<p>Untested idea:</p>\n\n<pre><code>a:hover {background-color: #fff;}\nimg:hover { background-color: transparent;}\n</code><... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2119/"
] | I have a CSS rule like this:
```
a:hover { background-color: #fff; }
```
But this results in a bad-looking gap at the bottom on image links, and what's even worse, if I have transparent images, the link's background color can be seen through the image.
I have stumbled upon this problem many times before, but I alwa... | I tried to find some selector that would get only `<a>` elements that don't have `<img>` descendants, but couldn't find any...
About images with that bottom gap, you could do the following:
```
a img{vertical-align:text-bottom;}
```
This should get rid of the background showing up behind the image, but may throw of... |
273,969 | <p>I'm having a little bit of trouble making a sticky form that will remember what is entered in it on form submission if the value has double quotes. The problem is that the HTML is supposed to read something like:</p>
<pre><code><input type="text" name="something" value="Whatever value you entered" />
</code><... | [
{
"answer_id": 273976,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 5,
"selected": true,
"text": "<p>You want <a href=\"http://www.php.net/htmlentities\" rel=\"noreferrer\">htmlentities()</a>.</p>\n\n<p><code><input type=... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13281/"
] | I'm having a little bit of trouble making a sticky form that will remember what is entered in it on form submission if the value has double quotes. The problem is that the HTML is supposed to read something like:
```
<input type="text" name="something" value="Whatever value you entered" />
```
However, if the phrase... | You want [htmlentities()](http://www.php.net/htmlentities).
`<input type="text" value="<?php echo htmlentities($myValue); ?>">` |
273,970 | <p>Right now we've got web pages that show UI elements, and web pages that just process form submissions, and then redirect back to the UI pages. They do this using PHP's header() function:</p>
<pre><code>header("Location: /other_page.php");
</code></pre>
<p>This causes a 302 Found response to be sent; according to ... | [
{
"answer_id": 273989,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "<p>I've never used it myself... as it says in your link:</p>\n\n<blockquote>\n <p>Note: Many pre-HTTP/1.1 user agents do\n ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20903/"
] | Right now we've got web pages that show UI elements, and web pages that just process form submissions, and then redirect back to the UI pages. They do this using PHP's header() function:
```
header("Location: /other_page.php");
```
This causes a 302 Found response to be sent; according to the HTTP 1.1 spec, 302 is f... | You can use either, but the proper statuscode to use for redirect-after-post is 303.
The confusion has a historical explanation. Originally, 302 specified that the browser mustn't change the method of the redirected request. This makes it unfit for redirect-after-post, where you want the browser to issue a GET request... |
273,978 | <p>What makes all the words of a programming language actually do anything? I mean, what's actually happening to make the computer know what all of those words mean? If I verbally tell my my computer to do something, it doesn't do it, because it doesn't understand. So how exactly can these human words written into a la... | [
{
"answer_id": 273983,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>In the simplest case, a program called a <strong>compiler</strong> takes the programming language words you write and ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35661/"
] | What makes all the words of a programming language actually do anything? I mean, what's actually happening to make the computer know what all of those words mean? If I verbally tell my my computer to do something, it doesn't do it, because it doesn't understand. So how exactly can these human words written into a langu... | It all starts with the CPU or processor. Each processor type has a defined set of instructions it's able to perform. These instructions operate over ones and zeroes, which in turn represent whatever you wish them to: numbers, letters, even the instructions themselves.
At the lowest level, a zero is determined by the ... |
273,995 | <p>How does one prevent an inclusion cycle in C? ie. You shouldn't have a.h #include "b.h", which #include's "c.h" which #include's "a.h". I'm looking for a way of preventing this from happening using some sort of C directive.</p>
<p>I had originally thought this would've prevented this from happening:</p>
<p>Content... | [
{
"answer_id": 274008,
"author": "florin",
"author_id": 18308,
"author_profile": "https://Stackoverflow.com/users/18308",
"pm_score": 4,
"selected": true,
"text": "<p>It does work allright: the files <strong>are</strong> repeatedly included, but the sections protected by #ifdndef/#define... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19026/"
] | How does one prevent an inclusion cycle in C? ie. You shouldn't have a.h #include "b.h", which #include's "c.h" which #include's "a.h". I'm looking for a way of preventing this from happening using some sort of C directive.
I had originally thought this would've prevented this from happening:
Contents of a.h:
```
#i... | It does work allright: the files **are** repeatedly included, but the sections protected by #ifdndef/#define/#endif **are not** repeated, and that breaks the cycle.
Use your compiler to produce the preprocessed output and look at it for yourself. With GNU CC, you need to use "-E" option on the .c[pp] file, like this:
... |
274,009 | <p>I have a "username" TEdit on a Delphi 2006 login form. When the application starts up the user is asked to enter the username. The TEdit gets focus and the caret is placed in its horizontal center for some reason. As soon as anything is typed the caret is left aligned again and everything looks normal. </p>
<p>It i... | [
{
"answer_id": 274518,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 1,
"selected": false,
"text": "<p>Just a few additional questions: </p>\n\n<ol>\n<li>Is this problem on one pc or on more pc's?</li>\n<li>Does it oc... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35657/"
] | I have a "username" TEdit on a Delphi 2006 login form. When the application starts up the user is asked to enter the username. The TEdit gets focus and the caret is placed in its horizontal center for some reason. As soon as anything is typed the caret is left aligned again and everything looks normal.
It is also str... | I had also the same problem in Delphi 2007,
with a TEdit placed in a modal form called by double-clicking in a Grid.
I made some tests launching the same Form from a TSpeedButton.
I noticed that the problem with the TEdit appears only when the grid is focused.
**after more tests the problem appears to be a bug in ... |
274,011 | <p>I would like to know if there is software that, given a regex and of course some other constraints like length, produces random text that always matches the given regex.
Thanks</p>
| [
{
"answer_id": 274016,
"author": "kasperjj",
"author_id": 34240,
"author_profile": "https://Stackoverflow.com/users/34240",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of starting from a regexp, you should be looking into writing a small context free grammer, this will allow yo... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11906/"
] | I would like to know if there is software that, given a regex and of course some other constraints like length, produces random text that always matches the given regex.
Thanks | [Xeger](http://code.google.com/p/xeger) is capable of doing it:
```
String regex = "[ab]{4,6}c";
Xeger generator = new Xeger(regex);
String result = generator.generate();
assert result.matches(regex);
``` |
274,022 | <p>I very rarely meet any other programmers!</p>
<p>My thought when I first saw the token was "implies that" since that's what it would read it as in a mathematical proof but that clearly isn't its sense.</p>
<p>So how do I say or read "=>" as in:-</p>
<pre><code>IEnumerable<Person> Adults = people.Where(p =&g... | [
{
"answer_id": 274025,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 8,
"selected": true,
"text": "<p>I usually say 'such that' when reading that operator.</p>\n\n<p>In your example, p => p.Age > 16 reads as \"P, such ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29411/"
] | I very rarely meet any other programmers!
My thought when I first saw the token was "implies that" since that's what it would read it as in a mathematical proof but that clearly isn't its sense.
So how do I say or read "=>" as in:-
```
IEnumerable<Person> Adults = people.Where(p => p.Age > 16)
```
Or is there even... | I usually say 'such that' when reading that operator.
In your example, p => p.Age > 16 reads as "P, such that p.Age is greater than 16."
In fact, I asked this very question on the official linq pre-release forums, and Anders Hejlsberg responded by saying
>
> I usually read the => operator as "becomes" or "for which... |
274,024 | <p>I'm increasingly becoming aware that there must be major differences in the ways that regular expressions will be interpreted by browsers.<br />
As an example, a co-worker had written this regular expression, to validate that a file being uploaded would have a PDF extension:</p>
<pre><code>^(([a-zA-Z]:)|(\\{2}\w+)\... | [
{
"answer_id": 274052,
"author": "Mauricio",
"author_id": 33913,
"author_profile": "https://Stackoverflow.com/users/33913",
"pm_score": 1,
"selected": false,
"text": "<p>If you're using javascript, not enclosing the regex with slashes causes error in Firefox.</p>\n\n<p>Try doing <code>va... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12975/"
] | I'm increasingly becoming aware that there must be major differences in the ways that regular expressions will be interpreted by browsers.
As an example, a co-worker had written this regular expression, to validate that a file being uploaded would have a PDF extension:
```
^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))... | As far as I know firefox doesn't let you have the full path of an upload. Interpretation of regular expressions seems irrelevant in this case. I have yet to see any difference between modern browsers in regular expression execution. |
274,039 | <p>I would like to do this:</p>
<pre><code>[RequiresAuthentication(CompanyType.Client)]
public class FooController
{
public ActionResult OnlyClientUsersCanDoThis()
public ActionResult OnlyClientUsersCanDoThisToo()
[RequiresAuthentication]
public ActionResult AnyTypeOfUserCanDoThis()
</code></... | [
{
"answer_id": 274423,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 2,
"selected": false,
"text": "<p>We're looking into a way to expose other filters, but no promises.</p>\n\n<p>Applying a filter to the controller isn't real... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29493/"
] | I would like to do this:
```
[RequiresAuthentication(CompanyType.Client)]
public class FooController
{
public ActionResult OnlyClientUsersCanDoThis()
public ActionResult OnlyClientUsersCanDoThisToo()
[RequiresAuthentication]
public ActionResult AnyTypeOfUserCanDoThis()
```
You can see why t... | We're looking into a way to expose other filters, but no promises.
Applying a filter to the controller isn't really a "scope", it's merely a short-hand for applying it to all filters. Unfortunately, that means you can't include all but one action. One simple way you could do this is to put that one method in another c... |
274,051 | <p>Is keeping JMS connections / sessions / consumer always open a bad practice?</p>
<p>Code draft example:</p>
<pre><code>// app startup code
ConnectionFactory cf = (ConnectionFactory)jndiContext.lookup(CF_JNDI_NAME);
Connection connection = cf.createConnection(user,pass);
Session session = connection.createSession(... | [
{
"answer_id": 274204,
"author": "John Meagher",
"author_id": 3535,
"author_profile": "https://Stackoverflow.com/users/3535",
"pm_score": 4,
"selected": true,
"text": "<p>That is a very common and acceptable practice when dealing with long lived connections. For many JMS servers it is i... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35323/"
] | Is keeping JMS connections / sessions / consumer always open a bad practice?
Code draft example:
```
// app startup code
ConnectionFactory cf = (ConnectionFactory)jndiContext.lookup(CF_JNDI_NAME);
Connection connection = cf.createConnection(user,pass);
Session session = connection.createSession(true,Session.TRANSACT... | That is a very common and acceptable practice when dealing with long lived connections. For many JMS servers it is in fact preferable to creating a new connection each time it is needed. |
274,056 | <p>I'm setting up a User Control driven by a XML configuration. It is easier to explain by example. Take a look at the following configuration snippet:</p>
<pre><code><node>
<text lbl="Text:"/>
<checkbox lbl="Check me:" checked="true"/>
</node>
</code></pre>
<p>What I'm trying to achieve t... | [
{
"answer_id": 274249,
"author": "Keltex",
"author_id": 28260,
"author_profile": "https://Stackoverflow.com/users/28260",
"pm_score": 1,
"selected": false,
"text": "<p>You need something that looks more like this:</p>\n\n<pre><code><ItemTemplate>\n <%# GetContent(Page.GetData... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892/"
] | I'm setting up a User Control driven by a XML configuration. It is easier to explain by example. Take a look at the following configuration snippet:
```
<node>
<text lbl="Text:"/>
<checkbox lbl="Check me:" checked="true"/>
</node>
```
What I'm trying to achieve to translate that snippet into a single text box an... | One weekend later, here is what I came with as a solution. My main goal was to find something that will both work and allow you to keep specifying the exact content of the Item Template in markup. Doing things from code would work but can still be cumbersome.
The code should be straight forward to follow, but the gist... |
274,157 | <p>Wordpress provides a function called "the_permalink()" that returns, you guessed it!, the permalink to a given post while in a loop of posts.</p>
<p>I am trying to URL encode that permalink and when I execute this code:</p>
<pre><code><?php
print(the_permalink());
$permalink = the_permalink();
print($permalink)... | [
{
"answer_id": 274163,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 4,
"selected": false,
"text": "<p>According to the docs, <a href=\"http://codex.wordpress.org/Template_Tags/the_permalink\" rel=\"noreferrer\">... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33754/"
] | Wordpress provides a function called "the\_permalink()" that returns, you guessed it!, the permalink to a given post while in a loop of posts.
I am trying to URL encode that permalink and when I execute this code:
```
<?php
print(the_permalink());
$permalink = the_permalink();
print($permalink);
print(urlencode(the_p... | According to the docs, [`the_permalink`](http://codex.wordpress.org/Template_Tags/the_permalink) prints the permalink vs returns it. So, `urlencode` isn't getting anything to encode.
Try [`get_permalink`](http://codex.wordpress.org/Template_Tags/get_permalink).
---
[**EDIT**]
A little late for an edit, but I didn't... |
274,158 | <p>I have a very painful library which, at the moment, is accepting a C# string as a way to get arrays of data; apparently, this makes marshalling for pinvokes easier. </p>
<p>So how do I make a ushort array into a string by bytes? I've tried:</p>
<pre><code>int i;
String theOutData = "";
ushort[] theImageData = in... | [
{
"answer_id": 274205,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 1,
"selected": false,
"text": "<p>One thing you can do is switch from using a string to a stringBuilder it will help performance tremendously.</p>\n\... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21981/"
] | I have a very painful library which, at the moment, is accepting a C# string as a way to get arrays of data; apparently, this makes marshalling for pinvokes easier.
So how do I make a ushort array into a string by bytes? I've tried:
```
int i;
String theOutData = "";
ushort[] theImageData = inImageData.DataArray;
/... | P/Invoke can actually handle what you're after most of the time using StringBuilder to create writable buffers, for example see [pinvoke.net on GetWindowText and related functions](http://www.pinvoke.net/search.aspx?search=GetWindowText).
However, that aside, with data as ushort, I assume that it is encoded in UTF-16L... |
274,162 | <p>Is there a specific reason why I should be using the <code>Html.CheckBox</code>, <code>Html.TextBox</code>, etc methods instead of just manually writing the HTML?</p>
<pre><code><%= Html.TextBox("uri") %>
</code></pre>
<p>renders the following HTML</p>
<pre><code><input type="text" value="" name="uri" id... | [
{
"answer_id": 274169,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>I haven't been doing MVC too long, but I've already written some extension methods to generate menu tabs based on Ht... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | Is there a specific reason why I should be using the `Html.CheckBox`, `Html.TextBox`, etc methods instead of just manually writing the HTML?
```
<%= Html.TextBox("uri") %>
```
renders the following HTML
```
<input type="text" value="" name="uri" id="uri"/>
```
It guess it saves you a few key strokes but other tha... | There are huge benefits:
It has overloaded methods to pre-populate the values (formatted, and safe for HTML) just like the ViewState.
It allows built in support for the Validation features of MVC.
It allows you to override the rendering by providing your own DLL for changing the rendering (a sort of "Controller Adap... |
274,172 | <p>VB.Net2005</p>
<p>Simplified Code:</p>
<pre><code> MustInherit Class InnerBase(Of Inheritor)
End Class
MustInherit Class OuterBase(Of Inheritor)
Class Inner
Inherits InnerBase(Of Inner)
End Class
End Class
Class ChildClass
Inherits OuterBase(Of ChildClass)
End Class
Class ChildClassTwo
I... | [
{
"answer_id": 274169,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>I haven't been doing MVC too long, but I've already written some extension methods to generate menu tabs based on Ht... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | VB.Net2005
Simplified Code:
```
MustInherit Class InnerBase(Of Inheritor)
End Class
MustInherit Class OuterBase(Of Inheritor)
Class Inner
Inherits InnerBase(Of Inner)
End Class
End Class
Class ChildClass
Inherits OuterBase(Of ChildClass)
End Class
Class ChildClassTwo
Inherits OuterBase(Of ... | There are huge benefits:
It has overloaded methods to pre-populate the values (formatted, and safe for HTML) just like the ViewState.
It allows built in support for the Validation features of MVC.
It allows you to override the rendering by providing your own DLL for changing the rendering (a sort of "Controller Adap... |
274,179 | <p>I have followed the instructions to setup rxtx on windows from <a href="http://www.jcontrol.org/download/readme_rxtx_en.html" rel="nofollow noreferrer">http://www.jcontrol.org/download/readme_rxtx_en.html</a>.</p>
<p>What I did exactly was copy rxtxSerial.dll to "C:\Program Files\Java\jdk1.6.0_07\jre\bin"
and copie... | [
{
"answer_id": 274257,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 1,
"selected": false,
"text": "<p>Try putting <code>rxtxSerial.dll</code> in</p>\n\n<pre><code>C:\\Program Files\\Java\\jdk1.6.0_07\\jre\\lib\\bin\n ... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28462/"
] | I have followed the instructions to setup rxtx on windows from <http://www.jcontrol.org/download/readme_rxtx_en.html>.
What I did exactly was copy rxtxSerial.dll to "C:\Program Files\Java\jdk1.6.0\_07\jre\bin"
and copied RXTXcomm.jar to "C:\Program Files\Java\jdk1.6.0\_07\jre\lib\ext"
(my JAVA\_HOME variable is set to... | Try putting `rxtxSerial.dll` in
```
C:\Program Files\Java\jdk1.6.0_07\jre\lib\bin
^^^
``` |
274,185 | <p>Let's say there's a.gz, and b.gz.</p>
<p>$ gzip_merge a.gz b.gz -output c.gz</p>
<p>I'd like to have this program. Of course,</p>
<p>$ cat a.gz b.gz > c.gz</p>
<p>doesn't work. Because the final DEFLATE block of a.gz has BFINAL, and the GZIP header of b.gz. (Refer to RFC1951, RFC1952) But if you unset BFINAL, th... | [
{
"answer_id": 274190,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 6,
"selected": true,
"text": "<blockquote>\n <p>Of course, cat a.gz b.gz > c.gz doesn't work.</p>\n</blockquote>\n\n<p>Actually, it works just fine. ... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24349/"
] | Let's say there's a.gz, and b.gz.
$ gzip\_merge a.gz b.gz -output c.gz
I'd like to have this program. Of course,
$ cat a.gz b.gz > c.gz
doesn't work. Because the final DEFLATE block of a.gz has BFINAL, and the GZIP header of b.gz. (Refer to RFC1951, RFC1952) But if you unset BFINAL, throw away the second GZIP heade... | >
> Of course, cat a.gz b.gz > c.gz doesn't work.
>
>
>
Actually, it works just fine. I just tested it. It's even documented (sort of) in the gzip man page.
```
Multiple compressed files can be concatenated. In this case, gunzip
will extract all members at once. For example:
gzip -c file1 > f... |
274,196 | <p>I've got a large number of integer arrays. Each one has a few thousand integers in it, and each integer is generally the same as the one before it or is different by only a single bit or two. I'd like to shrink each array down as small as possible to reduce my disk IO. </p>
<p>Zlib shrinks it to about 25% of its... | [
{
"answer_id": 274201,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 0,
"selected": false,
"text": "<p>Did you try bzip2 for this?\n<a href=\"http://bzip.org/\" rel=\"nofollow noreferrer\">http://bzip.org/</a></p>\n\n<p... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23524/"
] | I've got a large number of integer arrays. Each one has a few thousand integers in it, and each integer is generally the same as the one before it or is different by only a single bit or two. I'd like to shrink each array down as small as possible to reduce my disk IO.
Zlib shrinks it to about 25% of its original siz... | If most of the integers really are the same as the previous, and the inter-symbol difference can usually be expressed as a single bit flip, this sounds like a job for XOR.
Take an input stream like:
```
1101
1101
1110
1110
0110
```
and output:
```
1101
0000
0010
0000
1000
```
a bit of pseudo code
```
compressed... |
274,265 | <p>I can't for the life of me find a way to make this work.</p>
<p>If I have 3 divs (a left sidebar, a main body, and a footer), how can I have the sidebar and main body sit next to each other without setting their positions as "absolute" or floating them? Doing either of these options result in the footer div not bei... | [
{
"answer_id": 274269,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 5,
"selected": true,
"text": "<p>You need to specify the footer to clear the float:</p>\n\n<pre><code>#footer{\n clear: both;\n}\n</code></pre>... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | I can't for the life of me find a way to make this work.
If I have 3 divs (a left sidebar, a main body, and a footer), how can I have the sidebar and main body sit next to each other without setting their positions as "absolute" or floating them? Doing either of these options result in the footer div not being pushed ... | You need to specify the footer to clear the float:
```
#footer{
clear: both;
}
```
This forces it under floated elements.
Other options for clear are left and right. |
274,286 | <p>I have a new VPS server, and I'm trying to get it to connect to another server at the same ISP. When I connect via mysql's command line tool, the connection is very fast.</p>
<p>When I use PHP to connect to the remote DB, the connection time may take up to 5 seconds. Queries after this are executed quickly.</p>
... | [
{
"answer_id": 274343,
"author": "acrosman",
"author_id": 24215,
"author_profile": "https://Stackoverflow.com/users/24215",
"pm_score": 2,
"selected": false,
"text": "<p>I would check to see what mode PHP is running in, is it for some reason running the scripts as a CGI. Basically is PH... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31479/"
] | I have a new VPS server, and I'm trying to get it to connect to another server at the same ISP. When I connect via mysql's command line tool, the connection is very fast.
When I use PHP to connect to the remote DB, the connection time may take up to 5 seconds. Queries after this are executed quickly.
This is not limi... | I ended up upgrading from PHP 5.1.6 to PHP 5.2.6, and the problem went away. It definitely was a DNS lookup issue within PHP, the following would take about 5 seconds to run:
```
gethostbyname('example.com')
```
I have a feeling IPV6 was an issue (mostly a hunch from reading about this online), but I don't have any ... |
274,315 | <p>I'm writing a C# app using the WebBrowser control, and I want all content I display to come from embedded resources - not static local files, and not remote files.</p>
<p>Setting the initial text of the control to an embedded HTML file works great with this code inspired by <a href="http://blog.topholt.com/2008/03/... | [
{
"answer_id": 274530,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>I can see three ways to get this going:</p>\n\n<p>1: write the files you need to flat files in the temp area, navi... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25362/"
] | I'm writing a C# app using the WebBrowser control, and I want all content I display to come from embedded resources - not static local files, and not remote files.
Setting the initial text of the control to an embedded HTML file works great with this code inspired by [this post](http://blog.topholt.com/2008/03/18/c-tr... | I can see three ways to get this going:
1: write the files you need to flat files in the temp area, navigate the `WebBrowser` to the html file, and delete them once the page has loaded
2: as you say, an embedded web-server - herhaps `HttpListener` - but note that this uses HTTP.SYS, and so requires admin priveleges (... |
274,319 | <p>I know that I need to tell my UITextField to resign first responder when I want to dismis the keyboard, but I'm not sure how to know when the user has pressed the "Done" key on the keyboard. Is there a notification I can watch for?</p>
| [
{
"answer_id": 274325,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 6,
"selected": false,
"text": "<p>If you connect the DidEndOnExit event of the text field to an action (IBAction) in InterfaceBuilder, it will be mess... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28422/"
] | I know that I need to tell my UITextField to resign first responder when I want to dismis the keyboard, but I'm not sure how to know when the user has pressed the "Done" key on the keyboard. Is there a notification I can watch for? | I set the delegate of the `UITextField` to my `ViewController` class.
In that class I implemented this method as following:
```
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
``` |
274,344 | <p>When you lock an object is that object locked throughout the whole application?</p>
<p>For Example, this snippet from C# 3.0 in a Nutshell Section 19.6.1 "Thread Safety and .NET Framework Types":</p>
<pre><code>static void AddItems( )
{
for (int i = 0; i < 100; i++)
lock (list)
list.Add ("I... | [
{
"answer_id": 274347,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 2,
"selected": false,
"text": "<p>The CLR doesn't automatically make static methods thread-safe; you must do it yourself.</p>\n\n<p>lock(list) uses that ob... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19490/"
] | When you lock an object is that object locked throughout the whole application?
For Example, this snippet from C# 3.0 in a Nutshell Section 19.6.1 "Thread Safety and .NET Framework Types":
```
static void AddItems( )
{
for (int i = 0; i < 100; i++)
lock (list)
list.Add ("Item " + list.Count);
... | ```
class UsefulStuff {
object _TheLock = new object { };
public void UsefulThingNumberOne() {
lock(_TheLock) {
//CodeBlockA
}
}
public void UsefulThingNumberTwo() {
lock(_TheLock) {
//CodeBlockB
}
}
}
```
`CodeBlockA` and `CodeBlockB` are pr... |
274,348 | <p>In my small WPF project, I have a <code>TabControl</code> with three tabs. On each tab is a <code>ListBox</code>. This project keeps track of groceries we need to buy. (No, it's not homework, it's for my wife.) So I have a list of <code>ShoppingListItem</code>s, each of which has a <code>Name</code> and a <code>... | [
{
"answer_id": 274421,
"author": "steve",
"author_id": 32103,
"author_profile": "https://Stackoverflow.com/users/32103",
"pm_score": 0,
"selected": false,
"text": "<p>Here are a couple of ideas:</p>\n\n<ol>\n<li>When tabs Bought and Needed load, filter them yourself by creating new colle... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5486/"
] | In my small WPF project, I have a `TabControl` with three tabs. On each tab is a `ListBox`. This project keeps track of groceries we need to buy. (No, it's not homework, it's for my wife.) So I have a list of `ShoppingListItem`s, each of which has a `Name` and a `Needed` property: `true` when we need the item, and `fal... | You can use a [CollectionViewSource](http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx) to reuse the original collection with a filter.
```
<Window.Resources>
<CollectionViewSource x:Key="NeededItems" Source="{Binding Items}" Filter="NeededCollectionViewSource_Filter" />
<C... |
274,360 | <p>Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)?</p>
| [
{
"answer_id": 274363,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 9,
"selected": true,
"text": "<pre><code>interface IInterface\n{\n}\n\nclass TheClass implements IInterface\n{\n}\n\n$cls = new TheClass();\nif ($cls instanc... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)? | ```
interface IInterface
{
}
class TheClass implements IInterface
{
}
$cls = new TheClass();
if ($cls instanceof IInterface) {
echo "yes";
}
```
You can use the "instanceof" operator. To use it, the left operand is a class instance and the right operand is an interface. It returns true if the object implements ... |
274,361 | <p>ok so my issue is i have the string '\222\222\223\225' which is stored as latin-1 in the db. What I get from django (by printing it) is the following string, 'ââââ¢' which I assume is the UTF conversion of it. Now I need to pass the string into a function that
does this operation: </p>
<pre><code>strdecryptedPas... | [
{
"answer_id": 274403,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": true,
"text": "<p>Your first error 'chr() arg not in range(256)' probably means you have underflowed the value, because chr cannot t... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35697/"
] | ok so my issue is i have the string '\222\222\223\225' which is stored as latin-1 in the db. What I get from django (by printing it) is the following string, 'ââââ¢' which I assume is the UTF conversion of it. Now I need to pass the string into a function that
does this operation:
```
strdecryptedPassword + chr(ord(... | Your first error 'chr() arg not in range(256)' probably means you have underflowed the value, because chr cannot take negative numbers. I don't know what the encryption algorithm is supposed to do when the inputcounter + 33 is more than the actual character representation, you'll have to check what to do in that case.
... |
274,375 | <p>I want to setup a statistics monitoring platform to watch a specific service, but I'm not quiet sure how to go about it. Processing the intercepted data isn't my concern, just how to go about it. One idea was to setup a proxy between the client application and the service so that all TCP traffic went first to my p... | [
{
"answer_id": 274393,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 1,
"selected": false,
"text": "<p>Exactly what are you trying to track? If you want a simple count of packets or bytes, or basic header information, t... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9908/"
] | I want to setup a statistics monitoring platform to watch a specific service, but I'm not quiet sure how to go about it. Processing the intercepted data isn't my concern, just how to go about it. One idea was to setup a proxy between the client application and the service so that all TCP traffic went first to my proxy,... | You didn't mention one approach: you could modify memcached or your client to record the statistics you need. This is probably the easiest and cleanest approach.
Between the proxy and the libpcap approach, there are a couple of tradeoffs:
```
- If you do the packet capture approach, you have to reassemble the TCP
s... |
274,384 | <p>Is anyone aware of any gems, tutorials, or solutions enabling a user to sign in to a website at one domain and automatically given access to other partner domains in the same session? </p>
<p>I have two rails apps running, let's call them App-A and App-B. App-A has a database associated with it, powering the regist... | [
{
"answer_id": 274640,
"author": "Ricardo Acras",
"author_id": 19224,
"author_profile": "https://Stackoverflow.com/users/19224",
"pm_score": 4,
"selected": true,
"text": "<p>You can set the same session_key in both apps. In appA environment.rb change the session_key, like this</p>\n\n<pr... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is anyone aware of any gems, tutorials, or solutions enabling a user to sign in to a website at one domain and automatically given access to other partner domains in the same session?
I have two rails apps running, let's call them App-A and App-B. App-A has a database associated with it, powering the registration and... | You can set the same session\_key in both apps. In appA environment.rb change the session\_key, like this
```
Rails::Initializer.run do |config|
...
config.action_controller.session = {
:session_key => '_portal_session',
:secret => '72bf006c18d459acf51836d2aea01e0afd0388f860fe4b07a9a57dedd25c631749ba9... |
274,408 | <p>I'm trying to create a database scripter tool for a local database I'm using.</p>
<p>I've been able to generate create scripts for the tables, primary keys, indexes, and foreign keys, but I can't find any way to generate create scripts for the table defaults.</p>
<p>For indexes, it's as easy as </p>
<pre><code>fo... | [
{
"answer_id": 274514,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 2,
"selected": false,
"text": "<p>While I haven't used SMO, I looked up MSDN and here is what I found.</p>\n\n<p>Table has a Columns property (column... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108/"
] | I'm trying to create a database scripter tool for a local database I'm using.
I've been able to generate create scripts for the tables, primary keys, indexes, and foreign keys, but I can't find any way to generate create scripts for the table defaults.
For indexes, it's as easy as
```
foreach (Index index in table.... | Try using [Scripter](https://learn.microsoft.com/en-US/dotnet/api/microsoft.sqlserver.management.smo.scripter?view=sql-smo-160) object with DriAll option set:
```
Server server = new Server(@".\SQLEXPRESS");
Database db = server.Databases["AdventureWorks"];
List<Urn> list = new List<Urn>();
DataTable dataTable = db.En... |
274,418 | <p>We're using Stored Procedures for <em>every query</em> to the DB. This seems incredibly un-<a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" rel="nofollow noreferrer">DRY</a>:</p>
<ol>
<li>Design the table</li>
<li>Design CRUD operation SPs for that table</li>
<li>Design code (preferably a class) to f... | [
{
"answer_id": 274424,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "<p>I suggest using a code-generation tool, such as NetTiers to generate your CRUD layer.</p>\n"
},
{
"answer_i... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25538/"
] | We're using Stored Procedures for *every query* to the DB. This seems incredibly un-[DRY](http://en.wikipedia.org/wiki/Don%27t_repeat_yourself):
1. Design the table
2. Design CRUD operation SPs for that table
3. Design code (preferably a class) to fill parameters and execute CRUD SPs
If we add a single column, or cha... | One tip to avoid modification of at least the SPs is writing them to use 'introspection', that is, deducing the column names and datatypes from the internal tables or the information\_schema views.
It's more complex code to write, but it'll avoid having to modify it each time the table changes, and it can be reused i... |
274,439 | <p>How to, in C# round any value to 10 interval? For example, if I have 11, I want it to return 10, if I have 136, then I want it to return 140. </p>
<p>I can easily do it by hand</p>
<pre><code>return ((int)(number / 10)) * 10;
</code></pre>
<p>But I am looking for an builtin algorithm to do this job, something lik... | [
{
"answer_id": 274447,
"author": "Raymond Martineau",
"author_id": 33952,
"author_profile": "https://Stackoverflow.com/users/33952",
"pm_score": 3,
"selected": false,
"text": "<p>Rounding a float to an integer is similar to (int)(x+0.5), as opposed to simply casting x - if you want a mul... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | How to, in C# round any value to 10 interval? For example, if I have 11, I want it to return 10, if I have 136, then I want it to return 140.
I can easily do it by hand
```
return ((int)(number / 10)) * 10;
```
But I am looking for an builtin algorithm to do this job, something like Math.Round(). The reason why I ... | There is no built-in function in the class library that will do this. The closest is [System.Math.Round()](http://msdn.microsoft.com/en-us/library/system.math.round.aspx) which is only for rounding numbers of types Decimal and Double to the nearest integer value. However, you can wrap your statement up in a extension m... |
274,457 | <p>I created a project using the default tab-controller project. I am using interface builder to edit the .xib file and add images and buttons. I hook them up to the FirstViewController object in interface builder (that I created and set it's class to the same as the code file). I hooked everything up using <code>IBout... | [
{
"answer_id": 274447,
"author": "Raymond Martineau",
"author_id": 33952,
"author_profile": "https://Stackoverflow.com/users/33952",
"pm_score": 3,
"selected": false,
"text": "<p>Rounding a float to an integer is similar to (int)(x+0.5), as opposed to simply casting x - if you want a mul... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] | I created a project using the default tab-controller project. I am using interface builder to edit the .xib file and add images and buttons. I hook them up to the FirstViewController object in interface builder (that I created and set it's class to the same as the code file). I hooked everything up using `IBoutlets` an... | There is no built-in function in the class library that will do this. The closest is [System.Math.Round()](http://msdn.microsoft.com/en-us/library/system.math.round.aspx) which is only for rounding numbers of types Decimal and Double to the nearest integer value. However, you can wrap your statement up in a extension m... |
274,465 | <p>I have some question:</p>
<p>How to make a role based web application? Such as in forum sites, there is many user types, admin, moderator etc... is the roles of these user types stored in database or web.config? And when a user login to our site, how to control this users roles? In short I want to learn about autho... | [
{
"answer_id": 274468,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": false,
"text": "<p>Check this articles and videos:</p>\n\n<ul>\n<li><a href=\"http://msdn.microsoft.com/en-us/library/yh26yfzy.... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439507/"
] | I have some question:
How to make a role based web application? Such as in forum sites, there is many user types, admin, moderator etc... is the roles of these user types stored in database or web.config? And when a user login to our site, how to control this users roles? In short I want to learn about authorization a... | @Mavera:
Basicly, its the concept of having your own users table in your own database, where you can manage permissions and store login information (Properly hashed of course). In the case of a multi-level permission scheme, I usually use two or more tables, for example:
```
TblUsers:
--------------------------------... |
274,469 | <p>This works (prints, for example, “3 arguments”):</p>
<pre><code>to run argv
do shell script "echo " & (count argv) & " arguments"
end run
</code></pre>
<p>This doesn't (prints only “Argument 3: three”, and not the previous two arguments):</p>
<pre><code>to run argv
do shell script "echo " & (c... | [
{
"answer_id": 274526,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 0,
"selected": false,
"text": "<p>Your problem appears to be unrelated to the loop, or the use of argv, for that matter. Here's a much simpler test ca... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30461/"
] | This works (prints, for example, “3 arguments”):
```
to run argv
do shell script "echo " & (count argv) & " arguments"
end run
```
This doesn't (prints only “Argument 3: three”, and not the previous two arguments):
```
to run argv
do shell script "echo " & (count argv) & " arguments"
repeat with i from... | Try this to avoid having to use the temporary file.
```
to run argv
set accumulator to do shell script "echo " & (count argv) & " arguments" altering line endings false
repeat with i from 1 to (count argv)
set ln to do shell script "echo 'Argument " & i & ": " & (item i of argv) & "'" a... |
274,474 | <p>My usage case is compiling generated source files from a java program using the ToolProvider and JavaCompiler classes provided in JDK 6. The source files contain references to classes in the context classloader (it runs in a J2EE container), but not in the system classloader. My understanding is that by default the... | [
{
"answer_id": 335708,
"author": "tcurdt",
"author_id": 33165,
"author_profile": "https://Stackoverflow.com/users/33165",
"pm_score": 1,
"selected": false,
"text": "<p>Another option is to use <a href=\"http://commons.apache.org/jci/usage.html\" rel=\"nofollow noreferrer\">Commons JCI</a... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33897/"
] | My usage case is compiling generated source files from a java program using the ToolProvider and JavaCompiler classes provided in JDK 6. The source files contain references to classes in the context classloader (it runs in a J2EE container), but not in the system classloader. My understanding is that by default the Too... | If you know the classpath to the files that are known to the contextclassloader you can pass them to the compiler:
```
StandardJavaFileManager fileManager = compiler.getStandardFileManager(this /* diagnosticlistener */, null, null);
// get compilationunits from somewhere, for instance via fileManager.getJavaFileOb... |
274,482 | <p>I am just getting started with CodeIgniter, and I am trying to hash out my regular modules/functions to get them working properly within the MVC framework. I have a few specific questions for anyone who has a strong CodeIgniter background:</p>
<p><strong>SESSIONS</strong></p>
<p>The CodeIgniter session stores sess... | [
{
"answer_id": 274506,
"author": "John McCollum",
"author_id": 22946,
"author_profile": "https://Stackoverflow.com/users/22946",
"pm_score": 2,
"selected": false,
"text": "<p>The newly released CI 1.7 handles sessions in the database (if you're using one). </p>\n\n<p>However, CI is desig... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] | I am just getting started with CodeIgniter, and I am trying to hash out my regular modules/functions to get them working properly within the MVC framework. I have a few specific questions for anyone who has a strong CodeIgniter background:
**SESSIONS**
The CodeIgniter session stores session data on the client side in... | The newly released CI 1.7 handles sessions in the database (if you're using one).
However, CI is designed to be loosely coupled, so you shouldn't notice any major issues if you decide to use $\_SESSION instead.
For your header / footer / navigation, you could create (for example) headerview.php, footerview.php, and ... |
274,493 | <p>When copying large files using <code>shutil.copy()</code>, you get no indication of how the operation is progressing..</p>
<p>I have put together something that works - it uses a simple ProgressBar class (which simple returns a simple ASCII progress bar, as a string), and a loop of <code>open().read()</code> and <c... | [
{
"answer_id": 274497,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": true,
"text": "<p>Two things:</p>\n\n<ul>\n<li>I would make the default block size a <em>lot</em> larger than 512. I would start with 163... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] | When copying large files using `shutil.copy()`, you get no indication of how the operation is progressing..
I have put together something that works - it uses a simple ProgressBar class (which simple returns a simple ASCII progress bar, as a string), and a loop of `open().read()` and `.write()` to do the actual copyin... | Two things:
* I would make the default block size a *lot* larger than 512. I would start with 16384 and perhaps more.
* For modularity, it might be better to have the `copy_with_prog` function not output the progress bar itself, but call a callback function so the caller can decide how to display the progress.
Perhap... |
274,496 | <p>I've built web apps before that utilize phpBB session, and user data. The common move is to use code like this:</p>
<pre><code>define('IN_PHPBB', true);
//replace $phpbb_root_path with path to your forum
$phpbb_root_path = '../forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.'... | [
{
"answer_id": 274497,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": true,
"text": "<p>Two things:</p>\n\n<ul>\n<li>I would make the default block size a <em>lot</em> larger than 512. I would start with 163... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24708/"
] | I've built web apps before that utilize phpBB session, and user data. The common move is to use code like this:
```
define('IN_PHPBB', true);
//replace $phpbb_root_path with path to your forum
$phpbb_root_path = '../forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
/... | Two things:
* I would make the default block size a *lot* larger than 512. I would start with 16384 and perhaps more.
* For modularity, it might be better to have the `copy_with_prog` function not output the progress bar itself, but call a callback function so the caller can decide how to display the progress.
Perhap... |
274,523 | <p>if Form.Release is called after using the form, it will free all related memory but not set the form variable to nil.</p>
<pre><code>if not assigned (Form1) then
begin
Application.CreateForm(Tform1, Form1);
try
// Do something
finally
Form1.Release
end;
end;
</code></pre>
<p>To be a... | [
{
"answer_id": 274535,
"author": "Roddy",
"author_id": 1737,
"author_profile": "https://Stackoverflow.com/users/1737",
"pm_score": 1,
"selected": false,
"text": "<p>In Delphi Win32, the appropriate way to free objects is to call </p>\n\n<pre><code>FreeAndNil(Form1)\n</code></pre>\n\n<p>T... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5015/"
] | if Form.Release is called after using the form, it will free all related memory but not set the form variable to nil.
```
if not assigned (Form1) then
begin
Application.CreateForm(Tform1, Form1);
try
// Do something
finally
Form1.Release
end;
end;
```
To be able to call the same code ... | Put the line
```
Form1 := nil;
```
just after the call to Release.
Release is just posting a CM\_RELEASE message to the Form which allows the Form to finish what's in its queue (event handlers) before handling the CM\_RELEASE message which means normally just calling Free.
So, after calling Release, you sho... |
274,529 | <p>Am working with django Publisher example, I want to list all the publishers in the db via my list_publisher.html template, my template looks like;</p>
<pre><code>{% extends "admin/base_site.html" %}
{% block title %}List of books by publisher{% endblock %}
{% block content %}
<div id="content-main">
<h1&g... | [
{
"answer_id": 274537,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "<p>A few suggestions:</p>\n\n<ul>\n<li>check that your base_site.html does define a <code>{% block content %}{% endblock %}</co... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26143/"
] | Am working with django Publisher example, I want to list all the publishers in the db via my list\_publisher.html template, my template looks like;
```
{% extends "admin/base_site.html" %}
{% block title %}List of books by publisher{% endblock %}
{% block content %}
<div id="content-main">
<h1>List of publisher:</h1>... | A few suggestions:
* check that your base\_site.html does define a `{% block content %}{% endblock %}` section to be refine by your my list\_publisher.html
* check the cardinality of your list: `{%regroup publisher by name as pub_list %}{{ pub_list|length }}`. That should at least display the length of your list. If i... |
274,560 | <p>Is there an easy way to verify that a given private key matches a given public key? I have a few <code>*.pub</code>and a few <code>*.key</code> files, and I need to check which go with which.</p>
<p>Again, these are pub/key files, DSA.</p>
<p>I would really prefer a one-liner of some sort...</p>
| [
{
"answer_id": 274562,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 1,
"selected": false,
"text": "<p>Encrypt something with the public key, and see which private key decrypts it.</p>\n<p>This <a href=\"http://www.cod... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17324/"
] | Is there an easy way to verify that a given private key matches a given public key? I have a few `*.pub`and a few `*.key` files, and I need to check which go with which.
Again, these are pub/key files, DSA.
I would really prefer a one-liner of some sort... | I found a way that seems to work better for me:
```
ssh-keygen -y -f <private key file>
```
That command will output the public key for the given private key, so then just compare the output to each \*.pub file. |
274,567 | <p>Can someone please derive a concrete example from the following:</p>
<p><a href="http://www.urdalen.com/blog/?p=210" rel="nofollow noreferrer">http://www.urdalen.com/blog/?p=210</a></p>
<p>..that shows how to deal with <code>one-to-many</code> and <code>many-to-many</code> relationships?</p>
<p>I've emailed the a... | [
{
"answer_id": 274684,
"author": "troelskn",
"author_id": 18180,
"author_profile": "https://Stackoverflow.com/users/18180",
"pm_score": 4,
"selected": true,
"text": "<p>The problem of ORM's (The impedance mismatch, as it's called) is precisely with relations. In an object graph (In-memor... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can someone please derive a concrete example from the following:
<http://www.urdalen.com/blog/?p=210>
..that shows how to deal with `one-to-many` and `many-to-many` relationships?
I've emailed the author some time ago but received no reply. I like his idea, but can't figure out how to implement it beyond simple sing... | The problem of ORM's (The impedance mismatch, as it's called) is precisely with relations. In an object graph (In-memory objects), relationships are pointers to other objects. In a relational database, relationships are reversed; This makes it impossible to do a simple mapping between the two models, and that is why OR... |