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 |
|---|---|---|---|---|---|---|
551,363 | <p>I know, there's JSONP, which involves server cooperation to name-space the data.</p>
<p>What is bothering me is the fact that the content of script tag <code>src</code> is <strong>evaluated</strong>, but it's <em>NOT</em> available to read.</p>
<pre><code><script src="http://www.google.com"></script>
<... | [
{
"answer_id": 551377,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure this is at all possible due to browser security policies.</p>\n"
},
{
"answer_id": 551380,
... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50394/"
] | I know, there's JSONP, which involves server cooperation to name-space the data.
What is bothering me is the fact that the content of script tag `src` is **evaluated**, but it's *NOT* available to read.
```
<script src="http://www.google.com"></script>
```
All we need to figure out is how to namespace the data, tha... | HTML5 provides `window.postMessage` which provides a mechanism for safe cross domain messaging, and is supported by Firefox 3, Opera 9.6, and WebKit nightlies.
That said your suggestion above cannot work because it requires fundamentally different behaviour from javascript's `eval`. `eval` parses and executes the give... |
551,383 | <p>Coming from Eclipse and having been used to duplicate lines all the time, it's pretty strange finding out that Xcode has no such function. Or does it?</p>
<p>I know it's possible to change the system wide keybindings but that's not what I'm after.</p>
| [
{
"answer_id": 551386,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 2,
"selected": false,
"text": "<p>Triple click to select the whole line, command-c to select and command-v twice to duplicate it. It's not an Xcode f... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36904/"
] | Coming from Eclipse and having been used to duplicate lines all the time, it's pretty strange finding out that Xcode has no such function. Or does it?
I know it's possible to change the system wide keybindings but that's not what I'm after. | The whole point is NOT to use the `Cmd-C`/`Cmd-V` shortcuts. I have the same issue coming from IntelliJ, and being able to just duplicate lines with `Cmd-D` and delete them with `Cmd-Y` is a big time saver.
It's been bugging me ever since. However, it looks like someone else has found a [solution](http://flexgraphix.c... |
551,385 | <p>My <a href="http://dandoes.net" rel="nofollow noreferrer">website</a> passes both validation for both <a href="http://validator.w3.org/check?uri=http:%2F%2Fdandoes.net" rel="nofollow noreferrer">XHTML</a> and <a href="http://jigsaw.w3.org/css-validator/validator?uri=http:%2F%2Fdandoes.net" rel="nofollow noreferrer">... | [
{
"answer_id": 551416,
"author": "ullmark",
"author_id": 23044,
"author_profile": "https://Stackoverflow.com/users/23044",
"pm_score": 3,
"selected": true,
"text": "<p>When i make a centered page i do the following;</p>\n\n<p>set width for the \"page\"-div and fix margins and center the ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2596/"
] | My [website](http://dandoes.net) passes both validation for both [XHTML](http://validator.w3.org/check?uri=http:%2F%2Fdandoes.net) and [CSS](http://jigsaw.w3.org/css-validator/validator?uri=http:%2F%2Fdandoes.net). It looks fine in Firefox, Chrome, Safari, Opera, even IE 6 (alas, not IE 5.5 but who cares?). Why then, w... | When i make a centered page i do the following;
set width for the "page"-div and fix margins and center the content in the body.
```
#page {
width: 900px;
margin: 0 auto;
text-align: left;
}
body {
text-align: center;
}
```
Has always worked fine for me in all browsers... |
551,406 | <p>So I'm encrypting a string using the .net DESCryptoServiceProvider </p>
<p>Is it possible to restrict the character set of the encrypted string so that it doesnt contain specific character ranges?</p>
<p>For example / or \?</p>
| [
{
"answer_id": 551415,
"author": "Alex Reitbort",
"author_id": 11525,
"author_profile": "https://Stackoverflow.com/users/11525",
"pm_score": 1,
"selected": false,
"text": "<p>No, but you can encode it in <a href=\"http://en.wikipedia.org/wiki/Base64\" rel=\"nofollow noreferrer\">base64</... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46616/"
] | So I'm encrypting a string using the .net DESCryptoServiceProvider
Is it possible to restrict the character set of the encrypted string so that it doesnt contain specific character ranges?
For example / or \? | Is the idea that you want to go from a plaintext string to an encrypted string? If so, use an encoding supporting the full range of Unicode to convert from the plaintext to binary data, and base64 to convert from the encrypted binary to "safe" encrypted text.
So the steps of the pipeline are:
**Encryption**
* Conver... |
551,443 | <pre><code>require 'tk'
root = TkRoot.new { title "Hello world" }
TkLabel.new(root) do
text 'Hello world!'
end
Tk.mainloop
</code></pre>
<p>Where can i download Ruby TK? i googled but didnt find it. </p>
| [
{
"answer_id": 551444,
"author": "John T",
"author_id": 36457,
"author_profile": "https://Stackoverflow.com/users/36457",
"pm_score": 1,
"selected": false,
"text": "<p>On linux it is contained in the <strong>libtcltk-ruby</strong> package.</p>\n\n<pre>sudo apt-get install libtcltk-ruby</... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66437/"
] | ```
require 'tk'
root = TkRoot.new { title "Hello world" }
TkLabel.new(root) do
text 'Hello world!'
end
Tk.mainloop
```
Where can i download Ruby TK? i googled but didnt find it. | On linux it is contained in the **libtcltk-ruby** package.
```
sudo apt-get install libtcltk-ruby
```
On windows, the bindings are included with the one-click ruby installer.
-John |
551,458 | <p>The table in question is part of a database that a vendor's software uses on our network. The table contains metadata about files. The schema of the table is as follows</p>
<pre><code>Metadata
ResultID (PK, int, not null)
MappedFieldname (char(50), not null)
Fieldname (PK, char(50), not null)
Fieldvalue (text... | [
{
"answer_id": 551474,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": true,
"text": "<p>The indexing strategy entirely depends on how you query the table and how much performance you need to get out of the re... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1469014/"
] | The table in question is part of a database that a vendor's software uses on our network. The table contains metadata about files. The schema of the table is as follows
```
Metadata
ResultID (PK, int, not null)
MappedFieldname (char(50), not null)
Fieldname (PK, char(50), not null)
Fieldvalue (text, null)
```
Th... | The indexing strategy entirely depends on how you query the table and how much performance you need to get out of the respective queries.
A clustered index can force re-sorting rows physically (on disk) when out-of-sequence inserts are made (this is called "page split"). In a large table with no free space on the inde... |
551,468 | <p>I am writing a user authentication class. During the request there are a lot of references to the current user, so I would like to cache it in memory instead of calling the database ala singleton. I am thinking about using session and clearing it at the end of every request. </p>
<p>like:</p>
<pre><code> public st... | [
{
"answer_id": 551470,
"author": "Chad Moran",
"author_id": 25416,
"author_profile": "https://Stackoverflow.com/users/25416",
"pm_score": 4,
"selected": false,
"text": "<p>Use the <code>HttpContext</code> class. You can get to it either in the context of a controller of <code>HttpContex... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I am writing a user authentication class. During the request there are a lot of references to the current user, so I would like to cache it in memory instead of calling the database ala singleton. I am thinking about using session and clearing it at the end of every request.
like:
```
public static User Current() {... | ```
HttpContext.Items["user"] = user;
```
You can reference the context items during the entire request and it will be cleaned up at the end of it. |
551,471 | <p>I receive the follow exception:</p>
<pre><code>System.NotSupportedException : This stream does not support seek operations.
at System.Net.Sockets.NetworkStream.Seek(Int64 offset, SeekOrigin origin)
at System.IO.BufferedStream.FlushRead()
at System.IO.BufferedStream.WriteByte(Byte value)
</code></pre>
<p>T... | [
{
"answer_id": 551493,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>A <code>BufferedStream</code> simply acts to reduce the number of read/write calls to the underlying stream (which... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12631/"
] | I receive the follow exception:
```
System.NotSupportedException : This stream does not support seek operations.
at System.Net.Sockets.NetworkStream.Seek(Int64 offset, SeekOrigin origin)
at System.IO.BufferedStream.FlushRead()
at System.IO.BufferedStream.WriteByte(Byte value)
```
The follow link show that t... | **The solution** is to use two independent `BufferedStream`s, one for receiving and one for sending. And don't forget to flush the sending `BufferedStream` appropriately.
---
Since even in 2018 it seems hard to get a satisfying answer to this question, for the sake of humanity, here are my two cents:
The `NetworkStr... |
551,480 | <p>I need to implement a simple and efficient XSS Filter in C++ for <a href="http://cppcms.sourceforge.net" rel="nofollow noreferrer">CppCMS</a>. I can't use existing high quality filters
written in PHP because because it is high performance framework that uses C++.</p>
<p>The basic idea is provide a filter that have ... | [
{
"answer_id": 551522,
"author": "dr. evil",
"author_id": 40322,
"author_profile": "https://Stackoverflow.com/users/40322",
"pm_score": 3,
"selected": true,
"text": "<p>You can take a look at the Anti Samy project, trying to accomplish the same thing. It's Java and .NET though.</p>\n\n<u... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66522/"
] | I need to implement a simple and efficient XSS Filter in C++ for [CppCMS](http://cppcms.sourceforge.net). I can't use existing high quality filters
written in PHP because because it is high performance framework that uses C++.
The basic idea is provide a filter that have a while list of HTML tags and a white
list of o... | You can take a look at the Anti Samy project, trying to accomplish the same thing. It's Java and .NET though.
* <http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project#.NET_version>
* <http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project_.NET>
**Edit 1, A bit extra :**
You can potentially come up w... |
551,494 | <blockquote>
<p>Write code in your favorite language
and let Windows Task Manager represent
a sine wave in CPU Usage History.</p>
</blockquote>
<p>This is a technical interview quiz from Microsoft China.
I think it's a good question. Especially it's worth knowing how candidate understand and figure out the solut... | [
{
"answer_id": 551506,
"author": "Neil N",
"author_id": 55164,
"author_profile": "https://Stackoverflow.com/users/55164",
"pm_score": 2,
"selected": false,
"text": "<p>With the literally hundreds (thousands?) of threads a PC runs today, the only way I can think to even come close would b... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43997/"
] | >
> Write code in your favorite language
> and let Windows Task Manager represent
> a sine wave in CPU Usage History.
>
>
>
This is a technical interview quiz from Microsoft China.
I think it's a good question. Especially it's worth knowing how candidate understand and figure out the solution.
**Edit**: It's a ... | A thread time slice in Windows is 40ms, iirc, so that might be a good number to use as the 100% mark.
```
unsigned const TIME_SLICE = 40;
float const PI = 3.14159265358979323846f;
while(true)
{
for(unsigned x=0; x!=360; ++x)
{
float t = sin(static_cast<float>(x)/180*PI)*0.5f + 0.5f;
DWORD busy_... |
551,500 | <p>Is it confusing to design an API with multiple ways of achieving the same outcome? For example, I have my own <code>Date</code> library (which is a simple wrapper around the Java <code>Date</code>/<code>Calendar</code> classes to distinguish a <em>year-month-day</em>, <code>Date</code>, from an <em>instant-in-time</... | [
{
"answer_id": 551512,
"author": "Richard Levasseur",
"author_id": 36805,
"author_profile": "https://Stackoverflow.com/users/36805",
"pm_score": 2,
"selected": false,
"text": "<p>Its fine to provide convenience methods, the real problem is if each entry point begins to do behave in subtl... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16853/"
] | Is it confusing to design an API with multiple ways of achieving the same outcome? For example, I have my own `Date` library (which is a simple wrapper around the Java `Date`/`Calendar` classes to distinguish a *year-month-day*, `Date`, from an *instant-in-time*, `Instant` and provide mechanisms to convert between the ... | I've been doing academic research for the past 10 years on different issues that have to do with API usability in Java.
I can tell you that the statement about having one way to do things in Java is fairly incorrect. There are often *many* ways to do the same thing in Java. And unfortunately, they are often not consis... |
551,511 | <p>UPDATE: the HTML was not well formed. This was causing the script to appear in inner div. Please ignore the question.</p>
<p>IE ver<8 has a known bug (Internet explorer cannot display the page. Operation aborted)
If a script tries to append something to upper level block:</p>
<p>The bug is described <a href="h... | [
{
"answer_id": 551519,
"author": "ionelmc",
"author_id": 23658,
"author_profile": "https://Stackoverflow.com/users/23658",
"pm_score": 4,
"selected": true,
"text": "<p>Run your code in a domready/onload event handler.</p>\n"
},
{
"answer_id": 551525,
"author": "roborourke",
... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64106/"
] | UPDATE: the HTML was not well formed. This was causing the script to appear in inner div. Please ignore the question.
IE ver<8 has a known bug (Internet explorer cannot display the page. Operation aborted)
If a script tries to append something to upper level block:
The bug is described [here](http://support.microsof... | Run your code in a domready/onload event handler. |
551,538 | <p>Why is it not returning value in 'li'? What am i doing wrong?</p>
<pre><code>$("#list li").click(function() {
var selected = $(this).val();
alert(selected);
})
</code></pre>
| [
{
"answer_id": 551542,
"author": "Svante Svenson",
"author_id": 19707,
"author_profile": "https://Stackoverflow.com/users/19707",
"pm_score": 2,
"selected": false,
"text": "<p>A li doesn't have a value. Only form-related elements such as input, textarea and select have values.</p>\n"
}... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49632/"
] | Why is it not returning value in 'li'? What am i doing wrong?
```
$("#list li").click(function() {
var selected = $(this).val();
alert(selected);
})
``` | Did you want the HTML or text that is inside the `li` tag?
If so, use either:
```
$(this).html()
```
or:
```
$(this).text()
```
The `val()` is for form fields only. |
551,549 | <p>I'm just trying the ASP.Net Entity framework its the first time I've tried to use an ORM framework so bear with me If I'm barking up the wrong tree.</p>
<p>To simplify the problem I've got the following 2 tables</p>
<h2>Calendar</h2>
<p>CalendarID
UserID
Date
EventName</p>
<h2>Users</h2>
<p>UserId
Username</p>
... | [
{
"answer_id": 551718,
"author": "Odd",
"author_id": 11908,
"author_profile": "https://Stackoverflow.com/users/11908",
"pm_score": 0,
"selected": false,
"text": "<p>You need to tell the entity framework to load the Users for the Calendar.</p>\n\n<p>You can do this VIA the LINQ query, sim... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66058/"
] | I'm just trying the ASP.Net Entity framework its the first time I've tried to use an ORM framework so bear with me If I'm barking up the wrong tree.
To simplify the problem I've got the following 2 tables
Calendar
--------
CalendarID
UserID
Date
EventName
Users
-----
UserId
Username
I've added them both to my Ent... | for anyone interested I solved this by using the following code
```
UnityGamersEntities db2 = new UnityGamersEntities();
ObjectQuery<GameCalendar> gc = db2.GameCalendar.Include("GameTitles");
```
There seems to be a real lack of tutorials for the entity framework, unless you only ever want to work wi... |
551,563 | <p>Is it possible to update a templated AutoCompleteBox's BorderBrush at runtime? I can't seem to set the BorderBrush or the background.</p>
<p>Even base statements like TxtFoodSearch.BorderBrush = new SolidColorBrush(Colors.Red) don't seem to made a difference after the page has loaded.</p>
<p>My Xaml is below.</p>... | [
{
"answer_id": 551558,
"author": "denis phillips",
"author_id": 748,
"author_profile": "https://Stackoverflow.com/users/748",
"pm_score": 4,
"selected": false,
"text": "<p>Look at <a href=\"http://www.mono-project.com/Guide:Running_Mono_Applications\" rel=\"noreferrer\">mkbundle</a> usin... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66278/"
] | Is it possible to update a templated AutoCompleteBox's BorderBrush at runtime? I can't seem to set the BorderBrush or the background.
Even base statements like TxtFoodSearch.BorderBrush = new SolidColorBrush(Colors.Red) don't seem to made a difference after the page has loaded.
My Xaml is below.
```
... | You ask a loaded question. C# is merely a language and does not require the .NET Framework. The process of compiling it requires a compiler, which may or may not itself take a dependency on the .NET Framework (Microsoft's C# compiler does not -- it is written in native code). Your program will need to reference some as... |
551,578 | <p>I have four foreach loops that iterate through the collections and based on a condition do something. </p>
<p>Here is the code that I am writing now:</p>
<pre><code>boolean breakFlag = false;
String valueFromObj2 = null;
String valueFromObj4 = null;
for(Object1 object1: objects){
for(Object2 object2: object1){
... | [
{
"answer_id": 551581,
"author": "dwc",
"author_id": 57301,
"author_profile": "https://Stackoverflow.com/users/57301",
"pm_score": 0,
"selected": false,
"text": "<p>Throw an exception and catch it outside the loops? Use something that's \"considered harmful?\"</p>\n\n<p>It's a bit funny ... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3627/"
] | I have four foreach loops that iterate through the collections and based on a condition do something.
Here is the code that I am writing now:
```
boolean breakFlag = false;
String valueFromObj2 = null;
String valueFromObj4 = null;
for(Object1 object1: objects){
for(Object2 object2: object1){
// I get some valu... | Use a label on the outermost loop, and include this label in the `break` statement when you want to jump out of all the loops. In the example below, I've modified your code to use the label `OUTERMOST`:
```
String valueFromObj2 = null;
String valueFromObj4 = null;
OUTERMOST: for(Object1 object1: objects){
for(Object... |
551,579 | <p>I have something like the following, and after populating it with a arbitrary number of bits, I need to get the bytes to write out to a file. I don't see a way to do this and it seems useful, so I must be missing something. Any idea's?</p>
<pre><code>std::vector<bool> a;
a.push_back(true);
a.push_back(false)... | [
{
"answer_id": 551587,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 2,
"selected": false,
"text": "<p>Try this </p>\n\n<pre><code>void WriteOut(fstream& stream, const vector<bool>& data) {\n for (vector<... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59459/"
] | I have something like the following, and after populating it with a arbitrary number of bits, I need to get the bytes to write out to a file. I don't see a way to do this and it seems useful, so I must be missing something. Any idea's?
```
std::vector<bool> a;
a.push_back(true);
a.push_back(false);
a.push_back(false)... | `std::vector <bool>` does not actually contain bools (i.e.bytes) , it contains bits! This is mostly a missfeature and you are advised to use `std::deque <bool>`, which doesn't have this "feature" instead.
And if you want the storage to be contiguous, use `std::vector <char>`. |
551,589 | <p>Recently I <a href="https://stackoverflow.com/questions/550374/checking-for-null-before-tostring">asked a question</a> about how to clean up what I considered ugly code. One recommendation was to create an Extension Method that would perform the desired function and return back what I wanted. My first thought was ... | [
{
"answer_id": 551599,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": false,
"text": "<p>[OP] Definetely a handy way to go, but is it really worth the overhead of another class object? </p>\n\n<p>No extra cl... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51949/"
] | Recently I [asked a question](https://stackoverflow.com/questions/550374/checking-for-null-before-tostring) about how to clean up what I considered ugly code. One recommendation was to create an Extension Method that would perform the desired function and return back what I wanted. My first thought was 'Great! How cool... | Personally I think the "problems" of extension method readability are vastly overstated. If you concentrate on making your code easy to read in terms of *what* it's doing, that's more important most of the time than *how* it's doing it. If the developer wants to trace through and find out what's actually happening behi... |
551,602 | <p>I'm using a UIWebView with text in it. When the iPhone is rotated to landscape, text doesn't fill the now wider UIWebView width. I'm using P (paragraph) tags, which should not affect content filling landscape's width. The line breaks that are visible in portrait remain the same in landscape. In Interface Builder... | [
{
"answer_id": 687531,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I have the same problem. Reloading does not work, the only thing that seems to help a bit is to add the following line to t... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40106/"
] | I'm using a UIWebView with text in it. When the iPhone is rotated to landscape, text doesn't fill the now wider UIWebView width. I'm using P (paragraph) tags, which should not affect content filling landscape's width. The line breaks that are visible in portrait remain the same in landscape. In Interface Builder, I hav... | Here is a tweak though not a good thing to do, and something should be handled by apple itself
As you've noticed that things workfine when WebView is initialized in portrait and then you turn it to landscape. So.. what you can do is always initialize your webview with portrait bounds, add a selector which calls back a... |
551,613 | <p>Wrote a small app that accesses a bunch of search websites and puts the results in a word document, which gets run a few hundred times a day.</p>
<p>It saves individual search results in a number of local folders so the next time those words are searched, it grabs them locally instead of loading the website again.<... | [
{
"answer_id": 551631,
"author": "Jason Baker",
"author_id": 2147,
"author_profile": "https://Stackoverflow.com/users/2147",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately, this is a bit of a difficult question to answer for a couple of reasons:</p>\n\n<ol>\n<li>How do you d... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51498/"
] | Wrote a small app that accesses a bunch of search websites and puts the results in a word document, which gets run a few hundred times a day.
It saves individual search results in a number of local folders so the next time those words are searched, it grabs them locally instead of loading the website again.
This work... | You could use MSXML library & use XMLHttpRequest class to check for things
e.g.
```
On Error Resume Next
Dim request As MSXML2.XMLHTTP60
request.Open "http://www.google.com"
request.Send
Msgbox request.Status
```
The status will give you HTTP Status code of what happened to the request.
You might have to do some mo... |
551,617 | <p>By default error page in ZF looks like this: </p>
<pre><code>Fatal error: Uncaught exception 'Zend_Form_Exception' with message 'Method setDeault does not exist' in /usr/home/.../library/Zend/Form.php:2838
Stack trace:
#0 [internal function]: Zend_Form->__call('setDeault', Array)
#1 /usr/home/.../application/... | [
{
"answer_id": 551629,
"author": "Ferdinand Beyer",
"author_id": 34855,
"author_profile": "https://Stackoverflow.com/users/34855",
"pm_score": 2,
"selected": true,
"text": "<p>This is not an error page but a standard PHP output for uncaught exceptions. As far as I know there is no defaul... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66721/"
] | By default error page in ZF looks like this:
```
Fatal error: Uncaught exception 'Zend_Form_Exception' with message 'Method setDeault does not exist' in /usr/home/.../library/Zend/Form.php:2838
Stack trace:
#0 [internal function]: Zend_Form->__call('setDeault', Array)
#1 /usr/home/.../application/admin/controllers... | This is not an error page but a standard PHP output for uncaught exceptions. As far as I know there is no default error page in Zend Framework -- you will have to create your own by creating an appropriate view for the ErrorController. |
551,623 | <p>I am having an issue with a custom control rendering its contents (child controls) outside of the tag which leads to runtime errors and issues. In an attempt to simplify things as much as I can, I created the control below but it has the very same issue. I have tried inheriting from Control, WebControl and Composit... | [
{
"answer_id": 551717,
"author": "Canavar",
"author_id": 55351,
"author_profile": "https://Stackoverflow.com/users/55351",
"pm_score": 1,
"selected": false,
"text": "<p>Your control seems ok, I think you have a problem with adding your control to your page, </p>\n\n<p>Add a placeHolder t... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64262/"
] | I am having an issue with a custom control rendering its contents (child controls) outside of the tag which leads to runtime errors and issues. In an attempt to simplify things as much as I can, I created the control below but it has the very same issue. I have tried inheriting from Control, WebControl and CompositeCon... | Adding the control through the Page.Form property will render the button inside the form.
```
Page.Form.Controls.Add(new Button() { Text = "TestControl!" });
```
However, since the button is not contained within a block, such as a <div>, you might have some layout issues with this button. Use ScarletGarden's approac... |
551,640 | <p>I want to make sure my sweeper is being called as appropriate so I tried adding something like this:</p>
<pre><code>it "should clear the cache" do
@foo = Foo.new(@create_params)
Foo.should_receive(:new).with(@create_params).and_return(@foo)
FooSweeper.should_receive(:after_save).with(@foo)
post :cre... | [
{
"answer_id": 561271,
"author": "Patrick Ritchie",
"author_id": 4748,
"author_profile": "https://Stackoverflow.com/users/4748",
"pm_score": 3,
"selected": true,
"text": "<p>As you already mentioned caching has to be enabled in the environment for this to work. If it's disabled then my e... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6432/"
] | I want to make sure my sweeper is being called as appropriate so I tried adding something like this:
```
it "should clear the cache" do
@foo = Foo.new(@create_params)
Foo.should_receive(:new).with(@create_params).and_return(@foo)
FooSweeper.should_receive(:after_save).with(@foo)
post :create, @create_p... | As you already mentioned caching has to be enabled in the environment for this to work. If it's disabled then my example below will fail. It's probably a good idea to temporarily enable this at runtime for your caching specs.
'after\_save' is an instance method. You setup an expectation for a class method, which is wh... |
551,650 | <p>I'm writing a website in PHP that aggregates data from various other websites. I have a function 'returnPageSource' that takes a URL and returns the html from that URL as a string.</p>
<pre><code>function returnPageSource($url){
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
cu... | [
{
"answer_id": 551680,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 1,
"selected": false,
"text": "<p>I assume you've tried setting the timeout to 0.</p>\n\n<p>What HTTP status codes are these sites returning? Check <code>curl... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66730/"
] | I'm writing a website in PHP that aggregates data from various other websites. I have a function 'returnPageSource' that takes a URL and returns the html from that URL as a string.
```
function returnPageSource($url){
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt($ch,... | You should use [`curl_error()`](http://www.php.net/curl_error) to check which error has occurred (if any) |
551,652 | <p>I am trying to learn Ruby on Rails, I have followed the instructions from this <a href="http://www.buildingwebapps.com/articles/6491-setting-up-rails-on-windows-vista" rel="nofollow noreferrer">page</a> to get rails installed on my PC.</p>
<p>I am also trying to follow this <a href="http://rubyonrails.org/screencas... | [
{
"answer_id": 551653,
"author": "bluebrother",
"author_id": 60335,
"author_profile": "https://Stackoverflow.com/users/60335",
"pm_score": 0,
"selected": false,
"text": "<p>Are you possibly using a proxy but haven't listed localhost as proxy exception?</p>\n"
},
{
"answer_id": 55... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62951/"
] | I am trying to learn Ruby on Rails, I have followed the instructions from this [page](http://www.buildingwebapps.com/articles/6491-setting-up-rails-on-windows-vista) to get rails installed on my PC.
I am also trying to follow this [webcast](http://rubyonrails.org/screencasts) to try and learn the language and framewor... | Can you telnet to the port? Try:
```
telnet localhost 3000
```
That should tell you if the ports unavailable at the TCP level, or whether something's going on at the HTTP level.
Ping might not work if ICMP is disabled, which could be completely unrelated to your issue.
Also, try looking in your hosts file for any ... |
551,656 | <p>Using the latest version of the Microsoft Compiler (included with the Win7 SDK), I'm attempting to compile a source file that's encoded using UTF-8 with unicode line separators.</p>
<p>Unfortunately, the code will not compile -- even if I include the UTF-8 signature at the start of the file. For example, if I try ... | [
{
"answer_id": 551676,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "<p>When you say \"unicode line separators\" do you mean UTF-16/UCS-2 (ie., 16-bit characters)? If that's the case (t... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Using the latest version of the Microsoft Compiler (included with the Win7 SDK), I'm attempting to compile a source file that's encoded using UTF-8 with unicode line separators.
Unfortunately, the code will not compile -- even if I include the UTF-8 signature at the start of the file. For example, if I try to compile ... | When you say "unicode line separators" do you mean UTF-16/UCS-2 (ie., 16-bit characters)? If that's the case (the file is a mix of different encodings), I'd say the only reasonable fix is to fix the files.
If you mean the line endings are some other Unicode code point (still encoded in UTF-8), then you'll still need t... |
551,685 | <p>I want to protect some subdomains from the public. Restriction should be done against a whitelist of IPs.
Infinite loop due to the redirect is not a problem as its not the www-domain.</p>
<p>I tried this <a href="http://discussions.apple.com/message.jspa?messageID=2411725" rel="noreferrer">http://discussions.apple.... | [
{
"answer_id": 551703,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 3,
"selected": true,
"text": "<p>You have to combine the <code>RewriteCond</code> directives with AND instead of OR as you want to redirect if both conditi... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52025/"
] | I want to protect some subdomains from the public. Restriction should be done against a whitelist of IPs.
Infinite loop due to the redirect is not a problem as its not the www-domain.
I tried this <http://discussions.apple.com/message.jspa?messageID=2411725>, but couldnt get it to work.
However I did try this first
... | You have to combine the `RewriteCond` directives with AND instead of OR as you want to redirect if both conditions are true (therefor the IP address is neither *X* nor *Y*). So try this:
```
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^123\.45\.67\.89$
RewriteCond %{REMOTE_ADDR} !^213\.45\.67\.89$
RewriteRule ^ http:... |
551,701 | <p>I'm trying to use NHibernate with an existing database. In the data-model there is columns in each table that contains the time and username of the last update made to a row. How do I do this using NHibernate?</p>
<p>I tried to implement a interceptor that sets ChangeTime and ChangeUser in the entities before it ge... | [
{
"answer_id": 551786,
"author": "mookid8000",
"author_id": 6560,
"author_profile": "https://Stackoverflow.com/users/6560",
"pm_score": 5,
"selected": true,
"text": "<p>You should register a listener to the pre insert and pre update events. You can do it through your configuration like s... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4422/"
] | I'm trying to use NHibernate with an existing database. In the data-model there is columns in each table that contains the time and username of the last update made to a row. How do I do this using NHibernate?
I tried to implement a interceptor that sets ChangeTime and ChangeUser in the entities before it gets saved u... | You should register a listener to the pre insert and pre update events. You can do it through your configuration like so:
```
<hibernate-configuration>
...
<event type="pre-update">
<listener class="MyListener, MyAssembly"/>
</event>
<event type="pre-insert">
<listener class="MyListener... |
551,708 | <p>I have a medical database that keeps different types of data on patients: examinations, lab results, x-rays... each type of record exists in a separate table. I need to present this data on one table to show the patient's history with a particular clinic.</p>
<p>My question: what is the best way to do it? Should I ... | [
{
"answer_id": 551712,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 1,
"selected": false,
"text": "<p>Use a <a href=\"http://w3schools.com/sql/sql_join.asp\" rel=\"nofollow noreferrer\">JOIN</a> to get data from several table... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9476/"
] | I have a medical database that keeps different types of data on patients: examinations, lab results, x-rays... each type of record exists in a separate table. I need to present this data on one table to show the patient's history with a particular clinic.
My question: what is the best way to do it? Should I do a `SELE... | As others have said, JOIN is the way you'd normally do this. However, if there are multiple rows in one table for a patient then there's a chance you'll get data in some columns repeated across multiple rows, which often you don't want. In that case it's sometimes easier to use UNION or UNION ALL.
Let's say you have t... |
551,731 | <p>I am trying to assign some javascript variables in a Django template.</p>
<p>I am having a problem where the values I am assigning are being written to the page properly (I can see them in the page source), but still come up as <code>null</code>.</p>
<p>I am doing this:</p>
<pre><code><script type="text/javasc... | [
{
"answer_id": 551759,
"author": "Thomas Parslow",
"author_id": 65130,
"author_profile": "https://Stackoverflow.com/users/65130",
"pm_score": 0,
"selected": false,
"text": "<p>I've tried this out in a test app and it works fine (with item_list being a list of dicts with floats as the \"x... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12983/"
] | I am trying to assign some javascript variables in a Django template.
I am having a problem where the values I am assigning are being written to the page properly (I can see them in the page source), but still come up as `null`.
I am doing this:
```
<script type="text/javascript">
var coords = [];
{% for i in it... | Looks like I was missing one small thing. I was using a data series which was an array of arrays. Actually, the jquery flot plugin is expecting an array of series, which are arrays of arrays, so I needed a triple-nested array.
Changing from this:
```
$.plot($('#mapWrapper'), coords, options);
```
to this:
```
$.p... |
551,734 | <p>PHP 5.2.8 is refusing to load <code>php_pgsql.dll</code>, with the following error:</p>
<blockquote>
<p>Warning: PHP Startup: Unable to load dynamic library 'D:\PHP\ext\php_pgsql.dll' - The specified module could not be found.</p>
<p>in Unknown on line 0</p>
</blockquote>
<p>The .dll exists in PHP/ext/.</p>
<p>Has a... | [
{
"answer_id": 551768,
"author": "Jack Sleight",
"author_id": 39428,
"author_profile": "https://Stackoverflow.com/users/39428",
"pm_score": 0,
"selected": false,
"text": "<p>The only time I've seen this error (and the file name and ext path were definitely correct) was when I tried using... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] | PHP 5.2.8 is refusing to load `php_pgsql.dll`, with the following error:
>
> Warning: PHP Startup: Unable to load dynamic library 'D:\PHP\ext\php\_pgsql.dll' - The specified module could not be found.
>
>
> in Unknown on line 0
>
>
>
The .dll exists in PHP/ext/.
Has anyone else had this problem with PHP on Win... | Check out the info on the PHP PostgreSQL installation page: <http://us.php.net/manual/en/pgsql.installation.php>
>
> On a Windows server, configured with Apache, adding the following line to httpd.conf to load libpq.dll can save you a lot of time :
>
>
>
> ```
> LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.... |
551,769 | <p>I'm starting to mess with ASP.NET MVC and came across the issue of wanting to do some basic Paging. So I used this simple Linq statement (using the Northwind Database) to get 10 items for a specific page:</p>
<pre><code>var q = (from p in db.Orders
orderby p.OrderDate descending
... | [
{
"answer_id": 551776,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 2,
"selected": true,
"text": "<p>It tells the <code>ROW_NUMBER</code> function how to assign a number to each row, based on the expression within the p... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15861/"
] | I'm starting to mess with ASP.NET MVC and came across the issue of wanting to do some basic Paging. So I used this simple Linq statement (using the Northwind Database) to get 10 items for a specific page:
```
var q = (from p in db.Orders
orderby p.OrderDate descending
select p... | It tells the `ROW_NUMBER` function how to assign a number to each row, based on the expression within the parentheses. The rows don't actually get sorted according to this number within the subquery, though. That's what the sort in the outer query is for. |
551,771 | <p>Given an interface</p>
<pre><code>public interface IValueProvider
{
object GetValue(int index);
}
</code></pre>
<p>and a tree structure of instances of IValueProvider similar to a math expression tree.
I want to measure the time that is spent in the GetValue method of each node at runtime without an external pro... | [
{
"answer_id": 551812,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You don't say how quickly you expect each <code>GetValue</code> call to finish, so it's hard to give any definite advice...... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48722/"
] | Given an interface
```
public interface IValueProvider
{
object GetValue(int index);
}
```
and a tree structure of instances of IValueProvider similar to a math expression tree.
I want to measure the time that is spent in the GetValue method of each node at runtime without an external profiler.
GetValue could do ... | If you're trying to analyze performance instead of starting with a given method get an actual profile like Ants profiler and see where the real bottlenecks are. Many times when you assume why your application isn't being performant you end up looking and optimizing all of the wrong places and just waste a lot of time. |
551,778 | <p>The CSS active link style is being correctly applied in IE7, FF, and Safari but is not applied IE6.</p>
<pre><code>.side_nav a.active
{
color:#FFFFFF;
background-color:#9F1F63;
}
</code></pre>
<p>Interestingly the background color (background-color:#9F1F63;) is being applied in IE6 but not the font color ... | [
{
"answer_id": 551789,
"author": "Mark Hurd",
"author_id": 65714,
"author_profile": "https://Stackoverflow.com/users/65714",
"pm_score": 2,
"selected": false,
"text": "<p>Try adding a more specific selector to <code>.side_nav a.active</code> such as <code>div .side_nav a.active</code> wh... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5506/"
] | The CSS active link style is being correctly applied in IE7, FF, and Safari but is not applied IE6.
```
.side_nav a.active
{
color:#FFFFFF;
background-color:#9F1F63;
}
```
Interestingly the background color (background-color:#9F1F63;) is being applied in IE6 but not the font color (color:#FFFFFF;)
Any idea... | I tried copying your code, and the format did work.
Your problem is you see the link as visited - you have both formatting of the visited and active (so you have the purple background and the purple text).
You should override the color for visited links with the active class:
```
.side_nav a.active, .side_nav a.... |
551,797 | <p>I'm trying to find out how much time it takes to execute a Python statement, so I looked online and found that the standard library provides a module called <a href="http://docs.python.org/library/timeit.html" rel="noreferrer">timeit</a> that purports to do exactly that:</p>
<pre><code>import timeit
def foo():
... | [
{
"answer_id": 551804,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 8,
"selected": true,
"text": "<p>Change this line:</p>\n\n<pre><code>t = timeit.Timer(\"foo()\")\n</code></pre>\n\n<p>To this:</p>\n\n<pre><code... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] | I'm trying to find out how much time it takes to execute a Python statement, so I looked online and found that the standard library provides a module called [timeit](http://docs.python.org/library/timeit.html) that purports to do exactly that:
```
import timeit
def foo():
# ... contains code I want to time ...
d... | Change this line:
```
t = timeit.Timer("foo()")
```
To this:
```
t = timeit.Timer("foo()", "from __main__ import foo")
```
Check out the link you provided at the very bottom.
>
> To give the timeit module access to functions you define, you can pass a setup parameter which contains an import statement:
>
>
> ... |
551,803 | <p>I want to display HTML in a webpage. I've wrapped in a code block but the last two lines still execute/render. What am I doing wrong?</p>
<pre><code><pre><code>
div {background: brown;}
div.bluebg {background: blue;}
<div>default brown background</div>
<div class="base">blue backgrou... | [
{
"answer_id": 551808,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 1,
"selected": false,
"text": "<p>Judging by the contents of your post I assume you're talking about showing code in Markdown on Stack Overflow.</p>\n\n<p>Don... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40106/"
] | I want to display HTML in a webpage. I've wrapped in a code block but the last two lines still execute/render. What am I doing wrong?
```
<pre><code>
div {background: brown;}
div.bluebg {background: blue;}
<div>default brown background</div>
<div class="base">blue background</div>
</code></pre>
```
The last two line... | I do not think [those tags] mean what you think they mean.
`<pre>` allows you to preserve white space and line feeds. `<code>` allows you to semantically indicate that code is being displayed on your page. Both have some default styles (such as applying a fixed-width font), but neither one does anything to escape `<`,... |
551,814 | <p>I was wondering How To make a Form and Div have a max width of child elements. Eg in this example both the form and the outerDiv stretch the full width of the page. I would like the form and outerDiv to have a width of 200px. </p>
<p>This becomes a problem when I have this page in an iframe, because the width of th... | [
{
"answer_id": 551860,
"author": "Michael La Voie",
"author_id": 65843,
"author_profile": "https://Stackoverflow.com/users/65843",
"pm_score": 4,
"selected": true,
"text": "<p>I believe the \"proper\" way is to make them inline elements:</p>\n\n<pre><code>style=\"display: inline;\"\n</co... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64027/"
] | I was wondering How To make a Form and Div have a max width of child elements. Eg in this example both the form and the outerDiv stretch the full width of the page. I would like the form and outerDiv to have a width of 200px.
This becomes a problem when I have this page in an iframe, because the width of the page is ... | I believe the "proper" way is to make them inline elements:
```
style="display: inline;"
```
divs are block elements and fill their container,
spans are inline elements and shrink to fit their contents.
You can either use spans as containers or just add the above style to your divs.
Good luck! |
551,838 | <pre><code>class HelloObject {
void speak() {
System.out.println("Hello (from object)!");
}
}
class HelloTester {
public static void main(String[] args) {
HelloObject object = new HelloObject();
object.speak();
}
}
</code></pre>
<p>When I change the "HelloTester" class name to s... | [
{
"answer_id": 551849,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 3,
"selected": false,
"text": "<p>You need to change the file name, not just the class name.</p>\n\n<p>In Java, the .java and .class names have to be identic... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] | ```
class HelloObject {
void speak() {
System.out.println("Hello (from object)!");
}
}
class HelloTester {
public static void main(String[] args) {
HelloObject object = new HelloObject();
object.speak();
}
}
```
When I change the "HelloTester" class name to something like "Hell... | You need to change the file name, not just the class name.
In Java, the .java and .class names have to be identical to the class name.
Hence, each class has to go to a separate file with its name so that a separate .class file is created.
Putting two different classes in the same file is a C++ practice that works ... |
551,840 | <p>I am in the process of writing a blackjack code for python, and i was hoping someone would be able to tell me how to make it:</p>
<ol>
<li>Recognize what someone has typed i.e. "Hit" or "Stand" and react accordingly.</li>
<li>Calculate what the player's score is and whether it is an ace and a jack together, and aut... | [
{
"answer_id": 551852,
"author": "SquareCog",
"author_id": 15962,
"author_profile": "https://Stackoverflow.com/users/15962",
"pm_score": 4,
"selected": false,
"text": "<p>This can get you started:</p>\n\n<p><a href=\"http://docs.python.org/library/random.html\" rel=\"noreferrer\">http://... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am in the process of writing a blackjack code for python, and i was hoping someone would be able to tell me how to make it:
1. Recognize what someone has typed i.e. "Hit" or "Stand" and react accordingly.
2. Calculate what the player's score is and whether it is an ace and a jack together, and automatically wins.
O... | This can get you started:
<http://docs.python.org/library/random.html>
<http://docs.python.org/library/strings.html>
<http://docs.python.org/library/stdtypes.html>
<http://docs.python.org/reference/index.html>
I see you have added some code; that's good.
Think about the parts of your program that will need to exi... |
551,853 | <p>Has anyone noticed how creating new instances of a MovieClip (and likely other objects as well) in AIR causes some strange effects? If you use <a href="http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0/com/senocular/display/duplicateDisplayObject.as" rel="nofollow noreferrer">Senocular's method</... | [
{
"answer_id": 552679,
"author": "James Hay",
"author_id": 47339,
"author_profile": "https://Stackoverflow.com/users/47339",
"pm_score": 3,
"selected": true,
"text": "<p>i'd personally use flash.utils:</p>\n\n<pre><code>getQualifiedClassName(value:*):String\n</code></pre>\n\n<p>and </p>\... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66584/"
] | Has anyone noticed how creating new instances of a MovieClip (and likely other objects as well) in AIR causes some strange effects? If you use [Senocular's method](http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0/com/senocular/display/duplicateDisplayObject.as) by grabbing the object constructor an... | i'd personally use flash.utils:
```
getQualifiedClassName(value:*):String
```
and
```
getDefinitionByName(name:String):Object
```
And create an instance using the Class object
I'm sure there may be a reason why Senocular has used this method, but it may be worth trying replacing that line using these two method... |
551,872 | <p>I write Eclipse plugins and export some classes as an API while wanting to restrict access to other classes. </p>
<p>I follow the common Eclipse practice of separating these classes into a ".internal" subpackage.</p>
<p>However, then I can't use "package" or default level access on these classes since many of them... | [
{
"answer_id": 551921,
"author": "Stephen",
"author_id": 37193,
"author_profile": "https://Stackoverflow.com/users/37193",
"pm_score": 4,
"selected": true,
"text": "<p>Isn't it just a case of updating the META-INF/MANIFEST.MF to being a plug-in osgi project (if it's not already?). It sho... | 2009/02/15 | [
"https://Stackoverflow.com/questions/551872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23072/"
] | I write Eclipse plugins and export some classes as an API while wanting to restrict access to other classes.
I follow the common Eclipse practice of separating these classes into a ".internal" subpackage.
However, then I can't use "package" or default level access on these classes since many of them need to be used ... | Isn't it just a case of updating the META-INF/MANIFEST.MF to being a plug-in osgi project (if it's not already?). It should look something like:
```
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: My-plugin
Bundle-SymbolicName: com.mycompany.mypluginname
Bundle-Version: 1.0.0
Bundle-Vendor: MyCompany
Bund... |
551,880 | <p>What tools do you guys recommend for backing up files and SQL Server databases on Windows 2003?</p>
<p>I'm looking for tools to run daily backups of both files and SQL Server databases. Compress them up and stick them on NAS drives.</p>
<p>I'm looking for cheap / FREE options if possible.</p>
| [
{
"answer_id": 552745,
"author": "MrEdmundo",
"author_id": 52026,
"author_profile": "https://Stackoverflow.com/users/52026",
"pm_score": 2,
"selected": false,
"text": "<p>Here at my company I do the following.</p>\n\n<p>At the end of the day I take a full back-up, using a SQL Server job.... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62037/"
] | What tools do you guys recommend for backing up files and SQL Server databases on Windows 2003?
I'm looking for tools to run daily backups of both files and SQL Server databases. Compress them up and stick them on NAS drives.
I'm looking for cheap / FREE options if possible. | Here at my company I do the following.
At the end of the day I take a full back-up, using a SQL Server job. The syntax for this is well documented in BOL however here is an example:
```
BACKUP DATABASE [DATABASE]
TO DISK = '[PATH]\[DATABASE].BAK'
WITH INIT;
```
I then execute a .bat file that runs a com... |
551,884 | <p>I used to use doxygen lot for C++, and really like the ability to document function and method arguments inline using <code>///<</code> , or variations. Conversely I really <em>dislike</em> having to repeat arguments in the comments when not using the inline style (as most over code doc systems only support).</p>... | [
{
"answer_id": 553045,
"author": "mouviciel",
"author_id": 45249,
"author_profile": "https://Stackoverflow.com/users/45249",
"pm_score": 0,
"selected": false,
"text": "<p>I rembember having successfully used this notation for instance variables of a class but never tried on method argume... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32136/"
] | I used to use doxygen lot for C++, and really like the ability to document function and method arguments inline using `///<` , or variations. Conversely I really *dislike* having to repeat arguments in the comments when not using the inline style (as most over code doc systems only support).
So recently I've been sett... | Have you tried the syntax that is mentioned in the manual:
```
void foo(int v /**< [in] docs for input parameter v. */);
```
I tested that and it worked for me. |
551,901 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/5716423/c-sharp-sortable-collection-which-allows-duplicate-keys">C# Sortable collection which allows duplicate keys</a> </p>
</blockquote>
<p>Basically I'd like to make a Dictionary work with duplicate keys wit... | [
{
"answer_id": 551908,
"author": "Ryan Emerle",
"author_id": 62195,
"author_profile": "https://Stackoverflow.com/users/62195",
"pm_score": 2,
"selected": false,
"text": "<p>Not in the Fx < 3.5.. You can implement one, obviously, with a Dictionary of IList objects. But then you have ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54937/"
] | >
> **Possible Duplicate:**
>
> [C# Sortable collection which allows duplicate keys](https://stackoverflow.com/questions/5716423/c-sharp-sortable-collection-which-allows-duplicate-keys)
>
>
>
Basically I'd like to make a Dictionary work with duplicate keys without going into custom comparer implementations. Th... | If you're using .NET 3.5 then [Lookup](http://msdn.microsoft.com/en-us/library/bb460184.aspx) is probably what you're after. |
551,915 | <p>I am trying to do many different queries on a result set which has a <em>very</em> large creation time. To get performance gains I wish to use a temp table and just do many queries on this temp table.</p>
<p>Seems pretty standard. Yet I am struggling to share this temp table in dynamic SQL. As I understand it, each... | [
{
"answer_id": 551922,
"author": "LukeH",
"author_id": 55847,
"author_profile": "https://Stackoverflow.com/users/55847",
"pm_score": 3,
"selected": true,
"text": "<p>You could try using a global temporary table (ie, use <code>##MyTemp</code> rather than <code>#MyTemp</code> in your queri... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27765/"
] | I am trying to do many different queries on a result set which has a *very* large creation time. To get performance gains I wish to use a temp table and just do many queries on this temp table.
Seems pretty standard. Yet I am struggling to share this temp table in dynamic SQL. As I understand it, each SqlCommand objec... | You could try using a global temporary table (ie, use `##MyTemp` rather than `#MyTemp` in your queries), [with this caveat](http://msdn.microsoft.com/en-us/library/ms174979.aspx):
>
> Global temporary tables are
> automatically dropped when the session
> that created the table ends and all
> other tasks have stopp... |
551,931 | <p>I have 2 simple tables and a foreign key defined in SQL Server Express:</p>
<hr>
<p>Product </p>
<ul>
<li>ProductID [auto-inc]</li>
<li>Name</li>
<li>CompanyID [not-null]</li>
</ul>
<p>Company</p>
<ul>
<li>CompanyID [auto-inc]</li>
<li>Name</li>
</ul>
<p>FK_Product_Company</p>
<ul>
<li>Product.CompanyID = Com... | [
{
"answer_id": 553201,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "<p>You need to add the .Include method to your query.</p>\n\n<pre><code>var _db = new MyDBEntities();\nvar product = (from p in... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35690/"
] | I have 2 simple tables and a foreign key defined in SQL Server Express:
---
Product
* ProductID [auto-inc]
* Name
* CompanyID [not-null]
Company
* CompanyID [auto-inc]
* Name
FK\_Product\_Company
* Product.CompanyID = Company.CompanyID
---
I created an ADO.NET Entity Data Model and added all the tables to it.... | You need to add the .Include method to your query.
```
var _db = new MyDBEntities();
var product = (from p in _db.Product.Include("Company")
where p.ProductID == 3
select p).First();
``` |
551,953 | <p>Do you typically use the designer or do everything in the ASPX?</p>
<p>Are the resources you've found particularly helpful to come up to speed quickly on how to use this control? I've noticed the intellisense comments for this control are minimal.</p>
<p>I'm continuing to browse the documentation on Telerik's web... | [
{
"answer_id": 551997,
"author": "Jeffrey Cameron",
"author_id": 61344,
"author_profile": "https://Stackoverflow.com/users/61344",
"pm_score": 4,
"selected": true,
"text": "<p>We recently started using RADGrid on my team. We have found their LiveExamples to be very informative. The big... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61639/"
] | Do you typically use the designer or do everything in the ASPX?
Are the resources you've found particularly helpful to come up to speed quickly on how to use this control? I've noticed the intellisense comments for this control are minimal.
I'm continuing to browse the documentation on Telerik's web site, I'm wonderi... | We recently started using RADGrid on my team. We have found their LiveExamples to be very informative. The biggest part of easing use of RADGrid is not the grid itself but in how the data is populated. If you simply want to test the layout of the grid initially then you can use any collection that implements IEnumerabl... |
551,957 | <p>I am lazy - and I am using a SQLDataSource to populate my dropdownLists.</p>
<p>The Databind event for the databound objects is called before the Page.PreRender so I am doing something like this in the PreRender eventHandler:</p>
<pre><code>private void InitializeDropDown()
{
this.myDropDown.It... | [
{
"answer_id": 551997,
"author": "Jeffrey Cameron",
"author_id": 61344,
"author_profile": "https://Stackoverflow.com/users/61344",
"pm_score": 4,
"selected": true,
"text": "<p>We recently started using RADGrid on my team. We have found their LiveExamples to be very informative. The big... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | I am lazy - and I am using a SQLDataSource to populate my dropdownLists.
The Databind event for the databound objects is called before the Page.PreRender so I am doing something like this in the PreRender eventHandler:
```
private void InitializeDropDown()
{
this.myDropDown.Items.Insert(0, new Lis... | We recently started using RADGrid on my team. We have found their LiveExamples to be very informative. The biggest part of easing use of RADGrid is not the grid itself but in how the data is populated. If you simply want to test the layout of the grid initially then you can use any collection that implements IEnumerabl... |
551,965 | <p>i'm hosting a website through a hosting company [1] on a linux/apache server. until now i serve the different content through one script with parameters. an example url is</p>
<pre><code>www.mydomain.com/pages.php?date=1-10-2008
</code></pre>
<p>now i want to change the scheme the url is composed of to something w... | [
{
"answer_id": 551975,
"author": "Andy Hume",
"author_id": 46460,
"author_profile": "https://Stackoverflow.com/users/46460",
"pm_score": 0,
"selected": false,
"text": "<p>Rather than parse the url in your script, you should be able to handle the specific example above with Apache's ModRe... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65889/"
] | i'm hosting a website through a hosting company [1] on a linux/apache server. until now i serve the different content through one script with parameters. an example url is
```
www.mydomain.com/pages.php?date=1-10-2008
```
now i want to change the scheme the url is composed of to something which looks completely like... | Something like:
```
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . pages.php
```
should rewrite every request for a file or directory that doesn't exist to pages.php. This will allow you to keep static files (images, stylesheets, etc) in the same ... |
551,987 | <p>Instead of placing triggers on tables everywhere in an Oracle database, is there a Java API that I can use to read transactions off the Oracle transaction log?</p>
<p>My purpose is to be able to detect transactions going into a proprietary(vendor) database and react accordingly. We can't modify the database so that... | [
{
"answer_id": 552032,
"author": "Suroot",
"author_id": 64626,
"author_profile": "https://Stackoverflow.com/users/64626",
"pm_score": -1,
"selected": false,
"text": "<p>If you are running in *nix, there is a perl module that you could use to tail the file; then break down the lines for y... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428965/"
] | Instead of placing triggers on tables everywhere in an Oracle database, is there a Java API that I can use to read transactions off the Oracle transaction log?
My purpose is to be able to detect transactions going into a proprietary(vendor) database and react accordingly. We can't modify the database so that we do not... | There is LogMiner which is SQL based (and so you could access through JDBC).
```
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#sthref1875
```
Or you can look at Oracle Streams which reads the logs and generates 'logical change messages' into a queue from the log contents.
```
http://do... |
551,996 | <p>I am using <%= ClientID %> in the javascript to get the ID of a dynamically loaded user control. </p>
<p>Everything works fine until multiple instances of the same control are loaded. The ID points to the ClientID of the user control that was added last.</p>
<p>How do I solve this issue?</p>
<p><strong>EDIT:
... | [
{
"answer_id": 552032,
"author": "Suroot",
"author_id": 64626,
"author_profile": "https://Stackoverflow.com/users/64626",
"pm_score": -1,
"selected": false,
"text": "<p>If you are running in *nix, there is a perl module that you could use to tail the file; then break down the lines for y... | 2009/02/16 | [
"https://Stackoverflow.com/questions/551996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using <%= ClientID %> in the javascript to get the ID of a dynamically loaded user control.
Everything works fine until multiple instances of the same control are loaded. The ID points to the ClientID of the user control that was added last.
How do I solve this issue?
**EDIT:
I am doing a:
var clID = <%= Clie... | There is LogMiner which is SQL based (and so you could access through JDBC).
```
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#sthref1875
```
Or you can look at Oracle Streams which reads the logs and generates 'logical change messages' into a queue from the log contents.
```
http://do... |
552,025 | <p>Objective-C 2.0 has some new enhancements:</p>
<ul>
<li>garbage collection</li>
<li>fast enumeration: <code>for..in</code></li>
<li>properties</li>
<li>thread synchronization: @synchronized(self)</li>
<li>@try/@catch/@finally/@throw exception
handling</li>
</ul>
<p>I'm interested in using Objective-C 2.0 as a lang... | [
{
"answer_id": 552394,
"author": "sebnow",
"author_id": 64423,
"author_profile": "https://Stackoverflow.com/users/64423",
"pm_score": 1,
"selected": false,
"text": "<p>Apple uses a variant/fork of the standard GCC, in which Objective-C 2.0 support is built-in. As far as I know, none of t... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48048/"
] | Objective-C 2.0 has some new enhancements:
* garbage collection
* fast enumeration: `for..in`
* properties
* thread synchronization: @synchronized(self)
* @try/@catch/@finally/@throw exception
handling
I'm interested in using Objective-C 2.0 as a language to program portable code across multiple operating system plat... | Quote from [Cocotron gets some Objective-C 2.0 support via gcc 4.3.0](http://www.cocotron.org/blog/2008/03/cocotron-gets-some-objective-c-20.html):
>
> Recent Cocotron patches by Johannes
> also completely enable @try/@catch
> which had been present in the compiler
> but needed runtime support.
>
>
>
[www.coco... |
552,026 | <p>I was inspired by <a href="http://secretgeek.net/6min_program.asp" rel="nofollow noreferrer">this</a> (number 2) to make my hard-coded strings ugly. </p>
<p>How can I do this in VIM? </p>
| [
{
"answer_id": 552040,
"author": "Paul Beckingham",
"author_id": 14356,
"author_profile": "https://Stackoverflow.com/users/14356",
"pm_score": 3,
"selected": false,
"text": "<p>In your .vimrc:</p>\n\n<pre><code>highlight String guifg=1 guibg=11\n</code></pre>\n"
},
{
"answer_id":... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62701/"
] | I was inspired by [this](http://secretgeek.net/6min_program.asp) (number 2) to make my hard-coded strings ugly.
How can I do this in VIM? | The language-based files are stored in `$VIMRUNTIME/syntax`, one `.vim` file per language, so that's where you need to go to change things.
For example, my C file is stored in `C:\Program Files\Vim\vim70\syntax\c.vim` and, if you add the following line near the end, before the `let b:current_syntax = "c"`, you'll get ... |
552,048 | <p>When attempting to output an empty textarea element, the .NET XSLT processor collapses the element to its short form. Instead of this:</p>
<pre><code><textarea id="blah" name="blah"></textarea>
</code></pre>
<p>I get this:</p>
<pre><code><textarea id="blah" name="blah"/>
</code></pre>
<p>Which ... | [
{
"answer_id": 552055,
"author": "Chris Ballance",
"author_id": 1551,
"author_profile": "https://Stackoverflow.com/users/1551",
"pm_score": 3,
"selected": true,
"text": "<p>Find your answer via a similar question right <a href=\"https://stackoverflow.com/questions/336670/explicit-script-... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19112/"
] | When attempting to output an empty textarea element, the .NET XSLT processor collapses the element to its short form. Instead of this:
```
<textarea id="blah" name="blah"></textarea>
```
I get this:
```
<textarea id="blah" name="blah"/>
```
Which causes many web browsers (including IE and Firefox) to render the r... | Find your answer via a similar question right [here](https://stackoverflow.com/questions/336670/explicit-script-end-tag-always-converted-to-self-closing) on Stackoverflow.com :-)
[Here](http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.outputmethod.aspx) is further explanation from MSDN. |
552,053 | <p>Our application has a <code>CustomerNumber</code> field. We have hundreds of different people using the system (each has their own login and their own list of <code>CustomerNumber</code>s). An individual user might have at most 100,000 customers. Many have less than 100.</p>
<p>Some people only put actual numbe... | [
{
"answer_id": 552109,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 2,
"selected": false,
"text": "<p>Probably your best bet is to pre-calculate a separate column and use that for ordering and use the customer number for di... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14663/"
] | Our application has a `CustomerNumber` field. We have hundreds of different people using the system (each has their own login and their own list of `CustomerNumber`s). An individual user might have at most 100,000 customers. Many have less than 100.
Some people only put actual numbers into their customer number fields... | In Oracle 10g:
```
SELECT cust_name
FROM t_customer c
ORDER BY
REGEXP_REPLACE(cust_name, '[0-9]', ''), TO_NUMBER(REGEXP_SUBSTR(cust_name, '[0-9]+'))
```
This will sort by the first occurence of number, not regarding it's position, i. e.:
1. `customer1 < customer2 < customer10`
* `cust1omer ? customer1`
*... |
552,058 | <p>So I'm starting a project using Python after spending a significant amount of time in static land. I've seen some projects that make "interfaces" which are really just classes without any implementations. Before, I'd scoff at the idea and ignore that section of those projects. But now, I'm beginning to warm up to... | [
{
"answer_id": 552068,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 3,
"selected": false,
"text": "<p>Seems kind of unnecessary to me - when I'm writing classes like that I usually just make the base class (your <code>ISo... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | So I'm starting a project using Python after spending a significant amount of time in static land. I've seen some projects that make "interfaces" which are really just classes without any implementations. Before, I'd scoff at the idea and ignore that section of those projects. But now, I'm beginning to warm up to the i... | There are some cases where interfaces can be very handy. [Twisted](http://twistedmatrix.com/trac/) makes [fairly extensive use](http://twistedmatrix.com/projects/core/documentation/howto/components.html) of [Zope interfaces](http://wiki.zope.org/Interfaces/FrontPage), and in a project I was working on Zope interfaces w... |
552,070 | <p>I have an Android application in which I have my preferences in an XML file, which works fine. I now want to set one of the preferences using code instead of displaying the entire preference screen, how would I go about doing this?</p>
| [
{
"answer_id": 552380,
"author": "Will",
"author_id": 53498,
"author_profile": "https://Stackoverflow.com/users/53498",
"pm_score": 8,
"selected": true,
"text": "<p>I assume by preferences you are referring to your application's preferences and not Android phone settings.</p>\n\n<p>To st... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an Android application in which I have my preferences in an XML file, which works fine. I now want to set one of the preferences using code instead of displaying the entire preference screen, how would I go about doing this? | I assume by preferences you are referring to your application's preferences and not Android phone settings.
To store preferences between runs of you application you need to do the following
1. Create a SharedPreferences object
```
SharedPreferences settings = getSharedPreferences(String n, MODE_PRIVATE);
```
*Stri... |
552,071 | <p>I have a UserControl in WPF with numerous child controls which I would like to index like an array. These child controls are in the same grid control as other child controls which I am not interested in.</p>
<p>I'd like to be able to index these controls in a way similar to:</p>
<pre><code>someControl.Children[3];... | [
{
"answer_id": 552380,
"author": "Will",
"author_id": 53498,
"author_profile": "https://Stackoverflow.com/users/53498",
"pm_score": 8,
"selected": true,
"text": "<p>I assume by preferences you are referring to your application's preferences and not Android phone settings.</p>\n\n<p>To st... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33536/"
] | I have a UserControl in WPF with numerous child controls which I would like to index like an array. These child controls are in the same grid control as other child controls which I am not interested in.
I'd like to be able to index these controls in a way similar to:
```
someControl.Children[3];
```
With out havin... | I assume by preferences you are referring to your application's preferences and not Android phone settings.
To store preferences between runs of you application you need to do the following
1. Create a SharedPreferences object
```
SharedPreferences settings = getSharedPreferences(String n, MODE_PRIVATE);
```
*Stri... |
552,072 | <p>When a long-running process is being executed, it is a good practice to provide feedback to the user, for example, updating a progress bar.</p>
<p>Some FAQs for GUI libraries suggest something like this:</p>
<pre><code>function long_running_progress()
do_some_work()
update_progress_bar()
while finish
... | [
{
"answer_id": 552077,
"author": "vanja.",
"author_id": 33536,
"author_profile": "https://Stackoverflow.com/users/33536",
"pm_score": 1,
"selected": false,
"text": "<p>If you used a MVC paradigm you could have the Model publish its current progress state as a property, the Controller cou... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23657/"
] | When a long-running process is being executed, it is a good practice to provide feedback to the user, for example, updating a progress bar.
Some FAQs for GUI libraries suggest something like this:
```
function long_running_progress()
do_some_work()
update_progress_bar()
while finish
do_some_work()... | Provide a callback interface. The business logic will call its method every once in a while. The user layer will update the progress or whatever. If you want to allow cancellation – no problem, let the callback method have a return value which will indicate a need for cancellation. This will work regardless of number o... |
552,073 | <p>Python has pretty good date parsing but is the only way to recognize a datetime such as "Today 3:20 PM" or "Yesterday 11:06 AM" by creating a new date today and doing subtractions?</p>
| [
{
"answer_id": 552173,
"author": "drfloob",
"author_id": 10161,
"author_profile": "https://Stackoverflow.com/users/10161",
"pm_score": -1,
"selected": false,
"text": "<p>I am not yet completely up to speed on Python yet, but your question interested me, so I dug around a bit.</p>\n\n<p>D... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53569/"
] | Python has pretty good date parsing but is the only way to recognize a datetime such as "Today 3:20 PM" or "Yesterday 11:06 AM" by creating a new date today and doing subtractions? | A library that I like a lot, and I'm seeing more and more people use, is [python-dateutil](http://labix.org/python-dateutil) but unfortunately neither it nor the other traditional big datetime parser, [mxDateTime from Egenix](http://www.egenix.com/products/python/mxBase/mxDateTime/) can parse the word "tomorrow" in spi... |
552,108 | <p>Below is a page that handles a login script and I am wondering if I have put it any security holes. I have been reading articles on protecting from injections and others and wanted to make sure that my code is secure.</p>
<p>It is submitted via ajax and returns JSON based on the login being correct or not.</p>
<pre>... | [
{
"answer_id": 552113,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": true,
"text": "<p>You might want to use the POST method rather than GET with the login form, otherwise their password will appear in the U... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Below is a page that handles a login script and I am wondering if I have put it any security holes. I have been reading articles on protecting from injections and others and wanted to make sure that my code is secure.
It is submitted via ajax and returns JSON based on the login being correct or not.
```
<?php
ob_star... | You might want to use the POST method rather than GET with the login form, otherwise their password will appear in the URL and URLs aren't very secure (they might get bookmarked or sent to another server as a referral URL, for example). |
552,110 | <p>As a jQuery neophyte I am somewhat confused by the different contexts in which the <strong><em>this</em></strong> keyword is used. Sometimes it refers to a DOM element e.g. <em>this.id</em> and sometimes it refers to a jQuery object e.g. <em>$(this).val()</em>.</p>
<p><a href="http://remysharp.com/2007/04/12/jquer... | [
{
"answer_id": 552129,
"author": "Miles",
"author_id": 64474,
"author_profile": "https://Stackoverflow.com/users/64474",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>sometimes it refers to a jQuery object e.g. <em>$(this).val()</em>.</p>\n</blockquote>\n\n<p><code>this</... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2680373/"
] | As a jQuery neophyte I am somewhat confused by the different contexts in which the ***this*** keyword is used. Sometimes it refers to a DOM element e.g. *this.id* and sometimes it refers to a jQuery object e.g. *$(this).val()*.
[Remy Sharp's blog post](http://remysharp.com/2007/04/12/jquerys-this-demystified/ "this de... | Remy Sharp's post is confusing if you don't read it carefully, in my opinion. The meaning of `this` never changes. In the example you gave, there were 2 uses of `this`. As a DOM element in an event:
```
$('a').click(function() {
alert(this.tagName);
});
```
and wrapped as a jQuery object in an event:
```
$('a'... |
552,115 | <p>If I add "trace=true" into my directive on an asp.net 2.0 .aspx page, will it recycle my application pool?</p>
<p>I know if I enable tracing in web.config that will recycle the application pool.</p>
<p>The webserver is IIS 6.0.</p>
<p>Thanks.</p>
| [
{
"answer_id": 552129,
"author": "Miles",
"author_id": 64474,
"author_profile": "https://Stackoverflow.com/users/64474",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>sometimes it refers to a jQuery object e.g. <em>$(this).val()</em>.</p>\n</blockquote>\n\n<p><code>this</... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30639/"
] | If I add "trace=true" into my directive on an asp.net 2.0 .aspx page, will it recycle my application pool?
I know if I enable tracing in web.config that will recycle the application pool.
The webserver is IIS 6.0.
Thanks. | Remy Sharp's post is confusing if you don't read it carefully, in my opinion. The meaning of `this` never changes. In the example you gave, there were 2 uses of `this`. As a DOM element in an event:
```
$('a').click(function() {
alert(this.tagName);
});
```
and wrapped as a jQuery object in an event:
```
$('a'... |
552,130 | <p>When have you run into syntax that might be dated, never used or just plain obfuscated that you couldn't understand for the life of you.</p>
<p>For example, I never knew that comma is an actual operator in C. So when I saw the code</p>
<pre><code>if(Foo(), Bar())
</code></pre>
<p>I just about blew a gasket tryin... | [
{
"answer_id": 552136,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": false,
"text": "<p>C#'s ?? operator threw me for a loop the first time I saw it. Essentially it will return the LHS if it's non-null and... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23829/"
] | When have you run into syntax that might be dated, never used or just plain obfuscated that you couldn't understand for the life of you.
For example, I never knew that comma is an actual operator in C. So when I saw the code
```
if(Foo(), Bar())
```
I just about blew a gasket trying to figure out what was going on ... | C++'s syntax for a default constructor on a local variable. At first I wrote the following.
```
Student student(); // error
Student student("foo"); // compiles
```
This lead me to about an hour of reading through a cryptic C++ error message. Eventually a non-C++ newbie dropped by, laughed and pointed out my mista... |
552,131 | <p>I'm trying to read data in from a binary file and then store in a data structure for later use. The issue is I don't want to have to identify exactly what type it is when I'm just reading it in and storing it. I just want to store the information regarding what type of data it is and how much data of this certain ty... | [
{
"answer_id": 552143,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": true,
"text": "<p>You could copy it to the known data structure which makes life easier later on:</p>\n\n<pre><code>double x;\nmemcpy (&... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39189/"
] | I'm trying to read data in from a binary file and then store in a data structure for later use. The issue is I don't want to have to identify exactly what type it is when I'm just reading it in and storing it. I just want to store the information regarding what type of data it is and how much data of this certain type ... | You could copy it to the known data structure which makes life easier later on:
```
double x;
memcpy (&x,memory,sizeof(double));
```
or you could just refer to it as a cast value:
```
if (*((double*)(memory)) == 4.0) {
// blah blah blah
}
```
I believe a `char*` is the best way to read it in, since the size o... |
552,134 | <p>Up until today, I had always thought that decent compilers automatically convert struct pass-by-value to pass-by-reference if the struct is large enough that the latter would be faster. To the best of my knowledge, this seems like a no-brainer optimization. However, to satisfy my curiosity as to whether this actua... | [
{
"answer_id": 552138,
"author": "Edmund",
"author_id": 63991,
"author_profile": "https://Stackoverflow.com/users/63991",
"pm_score": 3,
"selected": false,
"text": "<p>One answer is that the compiler would need to detect that the called method does not modify the contents of the struct i... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23903/"
] | Up until today, I had always thought that decent compilers automatically convert struct pass-by-value to pass-by-reference if the struct is large enough that the latter would be faster. To the best of my knowledge, this seems like a no-brainer optimization. However, to satisfy my curiosity as to whether this actually h... | Don't forget that in C/C++ the compiler needs to be able to compile a call to a function based only on the function declaration.
Given that callers might be using only that information, there's no way for a compiler to compile the function to take advantage of the optimization you're talking about. The caller can't kn... |
552,135 | <p>Can someone tell me what the difference is between the 2 JSON parsers?</p>
<p><a href="https://github.com/douglascrockford/JSON-js/blob/master/json.js" rel="noreferrer">https://github.com/douglascrockford/JSON-js/blob/master/json.js</a><br>
<a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" ... | [
{
"answer_id": 552157,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 7,
"selected": true,
"text": "<p>From their code:</p>\n\n<pre><code>// Augment the basic prototypes if they have not already been augmented.\n// The... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can someone tell me what the difference is between the 2 JSON parsers?
<https://github.com/douglascrockford/JSON-js/blob/master/json.js>
<https://github.com/douglascrockford/JSON-js/blob/master/json2.js>
I have a JSON file from 2007-04-13 (It has methods such as `parseJSON`). I don't see these methods in any of th... | From their code:
```
// Augment the basic prototypes if they have not already been augmented.
// These forms are obsolete. It is recommended that JSON.stringify and
// JSON.parse be used instead.
if (!Object.prototype.toJSONString) {
Object.prototype.toJSONString = function (filter) {
return JSON.stringif... |
552,149 | <p>I have two projects. One is working and the other isn't however the differences between them is nothing that I think "should" be of any importance. The first project is the one that is broken and it is the one I am trying to fix. The second project is a little sample project that I created when the first project jus... | [
{
"answer_id": 552185,
"author": "geofftnz",
"author_id": 20122,
"author_profile": "https://Stackoverflow.com/users/20122",
"pm_score": 1,
"selected": false,
"text": "<p>Possibly change</p>\n\n<pre><code>SelectedItem=\"{Binding Path=SelectedSubscription, Mode=OneWayToSource}\" \n</code><... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have two projects. One is working and the other isn't however the differences between them is nothing that I think "should" be of any importance. The first project is the one that is broken and it is the one I am trying to fix. The second project is a little sample project that I created when the first project just w... | Sorry about the delay in getting an answer posted. There was some kind of issue with getting an Open ID up and running.
This is a seriously weird issue.
The resolution to this problem didn't come from the window at all. Prior to the window's show method being called there was another window that was opened as a dial... |
552,162 | <p>So kind of very similar to "<a href="https://stackoverflow.com/questions/452375/detecting-https-requests-in-php" title="Detecting https requests in php">Detecting https requests in php</a>":</p>
<p>Want to have <a href="https://example.com/pog.php" rel="nofollow noreferrer">https://example.com/pog.php</a> go to <a ... | [
{
"answer_id": 552327,
"author": "gahooa",
"author_id": 64004,
"author_profile": "https://Stackoverflow.com/users/64004",
"pm_score": 6,
"selected": true,
"text": "<p><strong>Keyword -- Load Balancer</strong></p>\n\n<p>The problem boils down to the fact that the load balancer is handling... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9314/"
] | So kind of very similar to "[Detecting https requests in php](https://stackoverflow.com/questions/452375/detecting-https-requests-in-php "Detecting https requests in php")":
Want to have <https://example.com/pog.php> go to <http://example.com/pog.php> or even vice versa.
Problems:
* Can't read anything from $\_SERVE... | **Keyword -- Load Balancer**
The problem boils down to the fact that the load balancer is handling SSL encryption/decryption and it is completely transparent to the webserver.
```
Request: Client -> 443or80 -> loadbalancer -> 80 -> php
Response: PHP -> 80 -> loadbalancer -> 443or80 -> Client
```
*The real question... |
552,170 | <p>I have a simple Grid control with some buttons that I want to be able to move around. The code below does work, but it takes a lot of effort to actually do the drag&drop and it is not clear where the drop will happen. I have to move the mouse around a lot to get to a state where the drop is not rejected. I would... | [
{
"answer_id": 553015,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately you have to handle all of those events.</p>\n"
},
{
"answer_id": 553052,
"author": "inferis",
... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65092/"
] | I have a simple Grid control with some buttons that I want to be able to move around. The code below does work, but it takes a lot of effort to actually do the drag&drop and it is not clear where the drop will happen. I have to move the mouse around a lot to get to a state where the drop is not rejected. I would apprec... | It looks like each empty grid item only exists on the border you've defined (I'm not sure why this is, possibly it's a known feature of containers). If you add a backgroundColor to each GridItem then dragEnter will be triggered over the whole area rather than just that border. |
552,187 | <p>what is the simplest way to parse the lat and long out of the following xml fragment. There is no namespace etc.</p>
<p>It is in a string variable. not a stream.</p>
<pre><code><poi>
<city>stockholm</city>
<country>sweden</country>
<gpoint>
<lat>51.... | [
{
"answer_id": 552211,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 4,
"selected": true,
"text": "<pre><code>using System.IO;\nusing System.Xml;\nusing System.Xml.XPath;\n</code></pre>\n\n<p>. . .</p>\n\n<pre><code> ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17194/"
] | what is the simplest way to parse the lat and long out of the following xml fragment. There is no namespace etc.
It is in a string variable. not a stream.
```
<poi>
<city>stockholm</city>
<country>sweden</country>
<gpoint>
<lat>51.1</lat>
<lng>67.98</lng>
</gpoint>
</poi>
```
... | ```
using System.IO;
using System.Xml;
using System.Xml.XPath;
```
. . .
```
string xml = @"<poi>
<city>stockholm</city>
<country>sweden</countr>
<gpoint>
<lat>51.1</lat>
... |
552,191 | <p>For clarification purposes I need the program to print the numbers that are input for a and b, not the actual letters a and b.<br>
Okay here's the revised program per yall's suggestions: </p>
<pre><code>int main (int argc, char *argv[])
{
int a; /*first number input*/
int b; /*second number input*/
... | [
{
"answer_id": 552200,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 3,
"selected": false,
"text": "<p>You're asking <code>printf()</code> to print the values of the boolean expressions (which always resolve to 1 or 0... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74994/"
] | For clarification purposes I need the program to print the numbers that are input for a and b, not the actual letters a and b.
Okay here's the revised program per yall's suggestions:
```
int main (int argc, char *argv[])
{
int a; /*first number input*/
int b; /*second number input*/
a = atoi(argv[1... | Based on your edit, I think you're looking for this:
```
#include <stdio.h>
int main (int argc, char *argv[]) {
int a; /*first number input*/
int b; /*second number input*/
a = atoi(argv[1]); /*assign to a*/
b = atoi(argv[2]); /*assign to b*/
if (a < b)
printf("%d < %d\n", a, b); /* a is... |
552,198 | <p>Good day,</p>
<p>Currently, we are using ByteArrayInputStream for our reset-able InputStream. My problem with it is that it consumes a lot of memory (it loads all the bytes it represents in memory unlike some other InputStream implementations).</p>
<p>My question then is, is there any lighter implementation of Inp... | [
{
"answer_id": 552200,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 3,
"selected": false,
"text": "<p>You're asking <code>printf()</code> to print the values of the boolean expressions (which always resolve to 1 or 0... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343428/"
] | Good day,
Currently, we are using ByteArrayInputStream for our reset-able InputStream. My problem with it is that it consumes a lot of memory (it loads all the bytes it represents in memory unlike some other InputStream implementations).
My question then is, is there any lighter implementation of InputStream which su... | Based on your edit, I think you're looking for this:
```
#include <stdio.h>
int main (int argc, char *argv[]) {
int a; /*first number input*/
int b; /*second number input*/
a = atoi(argv[1]); /*assign to a*/
b = atoi(argv[2]); /*assign to b*/
if (a < b)
printf("%d < %d\n", a, b); /* a is... |
552,202 | <p>So, right to the point, here's what I want (minus the poor quality)...</p>
<p><a href="http://www.hbperspective.com/alt3/site.jpg" rel="nofollow noreferrer">http://www.hbperspective.com/alt3/site.jpg</a></p>
<p>And here's what I've got...</p>
<p><a href="http://www.hbperspective.com/alt3/" rel="nofollow noreferre... | [
{
"answer_id": 552208,
"author": "Sampson",
"author_id": 54680,
"author_profile": "https://Stackoverflow.com/users/54680",
"pm_score": 3,
"selected": true,
"text": "<pre><code>div#container {\n width:500px; /* Same width as both columns */\n margin:auto; /* Will center the container */... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49294/"
] | So, right to the point, here's what I want (minus the poor quality)...
<http://www.hbperspective.com/alt3/site.jpg>
And here's what I've got...
<http://www.hbperspective.com/alt3/>
I'm trying to get those two transparent columns to be centered as they are in the pic. With this CSS layout I'm having a heck of a time... | ```
div#container {
width:500px; /* Same width as both columns */
margin:auto; /* Will center the container */
}
div#col1 {
float:left; /* allows side-by-side columns */
width:250px;
}
div#col2 {
float:left;
width:250px;
}
div.clear {
clear:both; /* Stops columns from extending past border... |
552,212 | <p>I'm debugging some opensource code on a 64-bit Solaris system, using GCC, that converts 2byte characters (<code>wchar_t</code>) to 4byte characters (<code>wchar_t</code>). Because Solaris like some other Unixes define wchar_t as 4byte, not 2byte like in Windows.</p>
<p>Now I fixed the problem, through laying it out... | [
{
"answer_id": 552241,
"author": "DevSolar",
"author_id": 60281,
"author_profile": "https://Stackoverflow.com/users/60281",
"pm_score": 0,
"selected": false,
"text": "<p>There shouldn't be a difference, ++ binds higher than *.</p>\n\n<p>A quick test.c doesn't show any difference, either:... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] | I'm debugging some opensource code on a 64-bit Solaris system, using GCC, that converts 2byte characters (`wchar_t`) to 4byte characters (`wchar_t`). Because Solaris like some other Unixes define wchar\_t as 4byte, not 2byte like in Windows.
Now I fixed the problem, through laying it out the pointer arithmetic over tw... | The code as written here is still buggy - when you combine c1 and c2 you need to use c2! That is, at the lines:
```
c1 = ((c1 - UNI_SUR_HIGH_START) << UNI_SHIFT) +
(c1 - UNI_SUR_LOW_START ) + UNI_BASE;
```
The third occurrence of c1 should actually be c2.
Additionally, it seems silly to initialize the src\_en... |
552,253 | <p>The application I work uses XML for save/restore purposes. Here's an example snippet:</p>
<pre><code><?xml version="1.0" standalone="yes"?>
<itemSet>
<item handle="2" attribute1="30" attribute2="blah"></item>
<item handle="5" attribute1="27" attribute2="blahblah"></item>
</it... | [
{
"answer_id": 552274,
"author": "Nick",
"author_id": 26240,
"author_profile": "https://Stackoverflow.com/users/26240",
"pm_score": 0,
"selected": false,
"text": "<p>I'd guess a regex of some sort is going to be your best option for efficiency. It's going to be faster than parsing the XM... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22489/"
] | The application I work uses XML for save/restore purposes. Here's an example snippet:
```
<?xml version="1.0" standalone="yes"?>
<itemSet>
<item handle="2" attribute1="30" attribute2="blah"></item>
<item handle="5" attribute1="27" attribute2="blahblah"></item>
</itemSet>
```
I want to be able to **efficiently pre-pr... | You are looking for a stream oriented XML parser that reads each node in your XML one at a a time rather then loading the whole thing into memory.
One of the best known is the [SAX - Simple API for XML](http://sourceforge.net/projects/sax/)
Here's a [good article](http://www.xml.com/pub/a/1999/11/cplus/index.html?p... |
552,263 | <p>I have a table, with two columns, Enter_Time and Leave_Time, how to write a CREATE TABLE script that enforces the constraint Leave_Time > Enter_Time?</p>
<p>Edit: Microsoft Access is used</p>
| [
{
"answer_id": 552270,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 2,
"selected": false,
"text": "<pre><code>CREATE TABLE foo (\n Leave_Time DATETIME NOT NULL, \n Enter_Time DATETIME NOT NULL, \n CONSTRAINT ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I have a table, with two columns, Enter\_Time and Leave\_Time, how to write a CREATE TABLE script that enforces the constraint Leave\_Time > Enter\_Time?
Edit: Microsoft Access is used | ```
CREATE TABLE foo (
Leave_Time DATETIME NOT NULL,
Enter_Time DATETIME NOT NULL,
CONSTRAINT CHK_TIMES CHECK (Leave_Time > Enter_Time));
``` |
552,282 | <p>In firefox, using this javascript:</p>
<pre><code>top.location.hash = "#here%20are%20spaces";
</code></pre>
<p>changes the browser url to:</p>
<pre><code>http://mysite.com/#here are spaces
</code></pre>
<p>I expected firefox to show the encoded spaces as %20 in the browser url.</p>
<ol>
<li>What's going on here... | [
{
"answer_id": 552298,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 3,
"selected": true,
"text": "<p><code>%20</code> are replaced with an empty space (in firefox 3) just for readability purpose. You shouldn't worry ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62255/"
] | In firefox, using this javascript:
```
top.location.hash = "#here%20are%20spaces";
```
changes the browser url to:
```
http://mysite.com/#here are spaces
```
I expected firefox to show the encoded spaces as %20 in the browser url.
1. What's going on here? Why is firefox not setting the url to the string as I pas... | `%20` are replaced with an empty space (in firefox 3) just for readability purpose. You shouldn't worry about it. |
552,297 | <p>I have a series of image thumbnails in a page. They are created using css sprites.</p>
<pre><code><div class="galleryImg1"></div>
<div class="galleryImg2 featured"></div>
<div class="galleryImg3"></div>
</code></pre>
<p>I was originally using <code>id="galleryImg1"</code> but ch... | [
{
"answer_id": 552310,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 1,
"selected": false,
"text": "<p>You could use a Regex, but using split and indexof will be understood by more programmers. Also for something so simple, may... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I have a series of image thumbnails in a page. They are created using css sprites.
```
<div class="galleryImg1"></div>
<div class="galleryImg2 featured"></div>
<div class="galleryImg3"></div>
```
I was originally using `id="galleryImg1"` but changed to using `class="galleryImg1"` because the images may appear in mul... | As far as I know, you're going to need a pretty basic regular expression, like so:
```
$("[class^=galleryImg]").click(function(Event) {
var id = this.className.match(/galleryImg(\d+)/)[1];
console.log(id);
});
```
If you're particularly averse to this, though, you can use something like this, which won't val... |
552,317 | <p>I am trying to implement GZip compression for my asp.net page (including my CSS and JS files). I tried the following code, but it only compresses my .aspx page (found it from <a href="http://developer.yahoo.com/yslow/" rel="nofollow noreferrer">YSlow</a>)</p>
<pre><code>HttpContext context = HttpContext.Current;
co... | [
{
"answer_id": 552324,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 6,
"selected": true,
"text": "<p>For compressing JS & CSS files you actually have to handle that at the IIS level, since these files are rendered... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45261/"
] | I am trying to implement GZip compression for my asp.net page (including my CSS and JS files). I tried the following code, but it only compresses my .aspx page (found it from [YSlow](http://developer.yahoo.com/yslow/))
```
HttpContext context = HttpContext.Current;
context.Response.Filter = new GZipStream(context.Resp... | For compressing JS & CSS files you actually have to handle that at the IIS level, since these files are rendered directly without the ASP.NET runtime.
You could make a JSX & CSSX extension mapping in IIS to the aspnet\_isapi.dll and then take advantage of your zip code, but IIS is likely to do a better job of this for... |
552,320 | <p>In a software development class at my university, the teacher kept mentioning that on a quiz we needed to make sure that a field returned by a getter needed to be "protected." I guess she meant that nothing outside the class should be able to change it. She didn't give much more of an explanation than that.</p>
<... | [
{
"answer_id": 552321,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 4,
"selected": true,
"text": "<p>You either use a collection and wrap it in Collections.unmodifiable*() or you defensively copy your array, collection or ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12999/"
] | In a software development class at my university, the teacher kept mentioning that on a quiz we needed to make sure that a field returned by a getter needed to be "protected." I guess she meant that nothing outside the class should be able to change it. She didn't give much more of an explanation than that.
For instan... | You either use a collection and wrap it in Collections.unmodifiable\*() or you defensively copy your array, collection or object if its **mutable** (which arrays always are).
For example:
```
class Foo {
private String[] bar = <some array contents>;
public String[] getBar() {
return bar == null ? bar... |
552,323 | <p>In PHP, will these always return the same values?</p>
<pre><code>//example 1
$array = array();
if ($array) {
echo 'the array has items';
}
// example 2
$array = array();
if (count($array)) {
echo 'the array has items';
}
</code></pre>
<p>Thank you!</p>
| [
{
"answer_id": 552331,
"author": "gahooa",
"author_id": 64004,
"author_profile": "https://Stackoverflow.com/users/64004",
"pm_score": 6,
"selected": true,
"text": "<p>From <a href=\"http://www.php.net/manual/en/language.types.boolean.php\" rel=\"noreferrer\">http://www.php.net/manual/en/... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] | In PHP, will these always return the same values?
```
//example 1
$array = array();
if ($array) {
echo 'the array has items';
}
// example 2
$array = array();
if (count($array)) {
echo 'the array has items';
}
```
Thank you! | From <http://www.php.net/manual/en/language.types.boolean.php>, it says that an empty array is considered FALSE.
---
(Quoted):
When converting to boolean, the following values are considered FALSE:
* the boolean FALSE itself
* the integer 0 (zero)
* the float 0.0 (zero)
* the empty string, and the string "0"
* **an ... |
552,328 | <p>Okey this is really strange. I have this script which basically downloads bunch of achieve files and extracts them. Usually those files are .zip files. Today I sat down and decided to make it work with rar files and I got stuck. At first I thought that the problem is in my unrar code, but it wasn't there. So I did:<... | [
{
"answer_id": 552346,
"author": "sth",
"author_id": 56338,
"author_profile": "https://Stackoverflow.com/users/56338",
"pm_score": 3,
"selected": true,
"text": "<p>Does the data maybe contain a \"carriage return\" character (\"\\r\") so that the first chunk is overwritten with subsequent... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54091/"
] | Okey this is really strange. I have this script which basically downloads bunch of achieve files and extracts them. Usually those files are .zip files. Today I sat down and decided to make it work with rar files and I got stuck. At first I thought that the problem is in my unrar code, but it wasn't there. So I did:
``... | Does the data maybe contain a "carriage return" character ("\r") so that the first chunk is overwritten with subsequent data when you try to display it? This would explain why you don't see the first chunk in your output, but not why you aren't able to decode it later on. |
552,329 | <p>I have a code file from the boto framework pasted below, all of the print statements are mine, and the one commented out line is also mine, all else belongs to the attributed author.</p>
<p>My question is what is the order in which instantiations and allocations occur in python when instantiating a class? The auth... | [
{
"answer_id": 552363,
"author": "gahooa",
"author_id": 64004,
"author_profile": "https://Stackoverflow.com/users/64004",
"pm_score": 4,
"selected": true,
"text": "<p><strong>A few python notes</strong></p>\n\n<p>When python executes the <strong>class</strong> block, it creates all of th... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66813/"
] | I have a code file from the boto framework pasted below, all of the print statements are mine, and the one commented out line is also mine, all else belongs to the attributed author.
My question is what is the order in which instantiations and allocations occur in python when instantiating a class? The author's code b... | **A few python notes**
When python executes the **class** block, it creates all of the "attributes" of that class as it encounters them. They are usually class variables as well as functions (methods), and the like.
So the value for "Manager.DefaultDomainName" is set when it is encountered in the class definition. Th... |
552,332 | <p>I would appreciate any help with this problem, I have spent hours trying to diagnose it myself to no avail and haven't received a single response when posting it to the Netbeans user list and the bugs list. </p>
<p>Netbeans is an excellent IDE, and I have loved it since switching over from Eclipse a few months back... | [
{
"answer_id": 552339,
"author": "Tim Matthews",
"author_id": 36157,
"author_profile": "https://Stackoverflow.com/users/36157",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://libusb-win32.sourceforge.net/#about\" rel=\"nofollow noreferrer\">libusb-win32</a> maybe?</p>\n"
... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/387224/"
] | I would appreciate any help with this problem, I have spent hours trying to diagnose it myself to no avail and haven't received a single response when posting it to the Netbeans user list and the bugs list.
Netbeans is an excellent IDE, and I have loved it since switching over from Eclipse a few months back. I do Jav... | [libusb-win32](http://libusb-win32.sourceforge.net/#about) maybe? |
552,341 | <p>I'm learning GWT and have started to get the hang of it. I'm at the point where my code is getting to be a spaghetti mess so I'm going back and factoring reasonable bits of it out as Composites. The first problem I ran into was that my tool support failed to give the new Composite class an initWidget() method. It... | [
{
"answer_id": 552644,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 2,
"selected": false,
"text": "<p>\"<a href=\"http://web.archive.org/web/20091027034401/http://www.pathf.com/blogs/2007/12/gwt-conferenc-9/\" rel=\... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2170994/"
] | I'm learning GWT and have started to get the hang of it. I'm at the point where my code is getting to be a spaghetti mess so I'm going back and factoring reasonable bits of it out as Composites. The first problem I ran into was that my tool support failed to give the new Composite class an initWidget() method. It did i... | I'm not sure if I understand what you are trying to do. But for all the Composite's I've written I've never overridden the initWidget method. Because Composite itself doesn't need to be initialized with a constructor, i.e. no need to call super() my constructors of widgets extending composite look something like:
```
... |
552,369 | <p>I have this in .bashrc;</p>
<blockquote>
<p>PS1='$'</p>
</blockquote>
<p>However, I see this still in terminal:</p>
<blockquote>
<p>mas-macbook:some/path mas$</p>
</blockquote>
<p>I want</p>
<blockquote>
<p>$</p>
</blockquote>
| [
{
"answer_id": 552372,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 0,
"selected": false,
"text": "<p>I think you need the <code>export</code> keyword:</p>\n\n<pre><code>export PS1='$'\n</code></pre>\n"
},
{
"answ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | I have this in .bashrc;
>
> PS1='$'
>
>
>
However, I see this still in terminal:
>
> mas-macbook:some/path mas$
>
>
>
I want
>
> $
>
>
> | `PS1` should already have been exported long before you get to your `.bashrc` file, at least for a login shell. In that case, setting `PS1` should simply overwrite the value (not its export status).
One thing to keep in mind is that bash itself does not run your `.bashrc` file for a login shell. The actual sequence of... |
552,382 | <p>I am trying to set a path to an XML file, which differs when run locally or on server.</p>
<p>How do I determine if the Flash is running locally? (I am thinking to check if the URL contains "<a href="http://localhost" rel="nofollow noreferrer">http://localhost</a>" but how do you get the window URL?)</p>
<p>Thanks... | [
{
"answer_id": 552405,
"author": "John Leidegren",
"author_id": 58961,
"author_profile": "https://Stackoverflow.com/users/58961",
"pm_score": 3,
"selected": false,
"text": "<p>You can ask the external window (container) for this information through the external API</p>\n\n<pre><code>if (... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36036/"
] | I am trying to set a path to an XML file, which differs when run locally or on server.
How do I determine if the Flash is running locally? (I am thinking to check if the URL contains "<http://localhost>" but how do you get the window URL?)
Thanks in advance | mokee is right in that you need to specify a relative path to access your XML when running locally. You should match this folder structure somewhere on the server as well. However there is often a need to to attach different base paths in front of this relative path to point to specific versions of these folders. For i... |
552,384 | <p>Given a cell number in the US (although other countries would be nice too), <strong>how to I go about figuring out the provider?</strong> Are there any web services that you know of or ETL dumps that I can use to get this information?</p>
<p>Ideally this component would accept a cell phone number and return a servi... | [
{
"answer_id": 552405,
"author": "John Leidegren",
"author_id": 58961,
"author_profile": "https://Stackoverflow.com/users/58961",
"pm_score": 3,
"selected": false,
"text": "<p>You can ask the external window (container) for this information through the external API</p>\n\n<pre><code>if (... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5642/"
] | Given a cell number in the US (although other countries would be nice too), **how to I go about figuring out the provider?** Are there any web services that you know of or ETL dumps that I can use to get this information?
Ideally this component would accept a cell phone number and return a service provider. | mokee is right in that you need to specify a relative path to access your XML when running locally. You should match this folder structure somewhere on the server as well. However there is often a need to to attach different base paths in front of this relative path to point to specific versions of these folders. For i... |
552,414 | <p>The following script stores all the files and directories in the array <code>@file_list</code>.</p>
<p>How do I only filter only files with the <code>.lt6</code> extension and none other than that? </p>
<pre><code>opendir (CURRDIR, $localdir);
@file_list = grep !/^\.\.?$/, readdir CURRDIR;
print STDOUT "Found File... | [
{
"answer_id": 552437,
"author": "Jim Counts",
"author_id": 36737,
"author_profile": "https://Stackoverflow.com/users/36737",
"pm_score": 3,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>grep(/\\.lt6$/i, readdir(CURRDIR))\n</code></pre>\n\n<p>I've used it many times. It wor... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53121/"
] | The following script stores all the files and directories in the array `@file_list`.
How do I only filter only files with the `.lt6` extension and none other than that?
```
opendir (CURRDIR, $localdir);
@file_list = grep !/^\.\.?$/, readdir CURRDIR;
print STDOUT "Found Files: @file_list\n";
```
cheers | Try this:
```
grep(/\.lt6$/i, readdir(CURRDIR))
```
I've used it many times. It works, although now I prefer to use [File::Next](http://search.cpan.org/dist/File-Next/) for this sort of thing.
Example:
```
use File::Next;
my $iter = File::Next::files( { file_filter => sub { /\.lt6$/ } }, $localdir )
while ( defi... |
552,415 | <p>In the window.onbeforeunload event is there a way to detect if the new request is a POST(on the same page) or a GET(going to a page)? It would also be great to see the new document.location.</p>
<pre><code>window.onbeforeunload = winClose;
function winClose() {
//Need a way to detect if it is a POST or GET
... | [
{
"answer_id": 552442,
"author": "Sampson",
"author_id": 54680,
"author_profile": "https://Stackoverflow.com/users/54680",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds like something you'd need to attach to a form, or specific links. If the event is raised by a link, and there is... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64027/"
] | In the window.onbeforeunload event is there a way to detect if the new request is a POST(on the same page) or a GET(going to a page)? It would also be great to see the new document.location.
```
window.onbeforeunload = winClose;
function winClose() {
//Need a way to detect if it is a POST or GET
if (needToConf... | This is how I just did it:
```
$(document).ready(function(){
var action_is_post = false;
$("form").submit(function () {
action_is_post = true;
});
window.onbeforeunload = confirmExit;
function confirmExit()
{
if (!action_is_post)
return 'You are trying to leave this page without saving the d... |
552,421 | <p>I'm writing a <a href="http://microformats.org" rel="nofollow noreferrer">microformats</a> parser in C# and am looking for some refactoring advice. This is probably the first "real" project I've attempted in C# for some time (I program almost exclusively in VB6 at my day job), so I have the feeling this question may... | [
{
"answer_id": 552457,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>Instead of a large switch statement you can construct a dictionary that maps the string to a delegate and look it up when y... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17862/"
] | I'm writing a [microformats](http://microformats.org) parser in C# and am looking for some refactoring advice. This is probably the first "real" project I've attempted in C# for some time (I program almost exclusively in VB6 at my day job), so I have the feeling this question may become the first in a series ;-)
Let m... | Mehrdad's approach is basically the one I'd suggest to start with, but as the first step out of potentially more.
You can use a simple `IDictionary<Type,Delegate>` (where each entry is actually from `T` to `Func<ParseContext,T>` - but that can't be expressed with generics) for single types (strings, primitives etc) bu... |
552,453 | <p>I need some help understanding the following Perl code snippet. I have the following two questions.</p>
<p>1.
What does local <code>*PIPER</code> mean? Even though I've done some Perl programming before the <code>local *</code> syntax is new to me. Is it a pointer?</p>
<p>2.
What is the purpose of </p>
<pre><code... | [
{
"answer_id": 552461,
"author": "Chris Lutz",
"author_id": 60777,
"author_profile": "https://Stackoverflow.com/users/60777",
"pm_score": 3,
"selected": false,
"text": "<p>1) \"<code>*PIPER</code>\" is a typeglob. It is \"<code>$PIPER</code>\", \"<code>@PIPER</code>\", and \"<code>%PIPER... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need some help understanding the following Perl code snippet. I have the following two questions.
1.
What does local `*PIPER` mean? Even though I've done some Perl programming before the `local *` syntax is new to me. Is it a pointer?
2.
What is the purpose of
```
curl http://www.somesite.net/cgi-bin/updateuser.c... | 1) "`*PIPER`" is a typeglob. It is "`$PIPER`", "`@PIPER`", and "`%PIPER`" (and I then some) all in one. They are declaring all `*PIPER` names local to the code snippet you have.
2) That's a shell command. It ends with a `|` which means that that command is being run, and it's output is being piped in as the input for ... |
552,462 | <p>I am using LINQ and am having a hard time understanding how I can make new "domain model" classes work within LINQ while querying across tables. I am using Linq to SQL, and C# in .NET 3.5.</p>
<p>Suppose I want an Extended Client class:</p>
<pre><code>public class ExtendedClient
{
public int ID { get; set; }... | [
{
"answer_id": 552488,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 4,
"selected": true,
"text": "<pre><code>public ExtendedClient getExtendedClient(int clientID)\n{\n var c = dc.GetTable<tClient>();\n var cs = dc... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35615/"
] | I am using LINQ and am having a hard time understanding how I can make new "domain model" classes work within LINQ while querying across tables. I am using Linq to SQL, and C# in .NET 3.5.
Suppose I want an Extended Client class:
```
public class ExtendedClient
{
public int ID { get; set; }
public string Nam... | ```
public ExtendedClient getExtendedClient(int clientID)
{
var c = dc.GetTable<tClient>();
var cs = dc.GetTable<tClientSetting>();
var q = from client in c
join setting in cs
on client.ClientID equals setting.ClientID
where client.ClientID == clientID
select ... |
552,466 | <p>Style sheet in master page is not working for one web page of asp.net application but it works for another web page.</p>
| [
{
"answer_id": 552502,
"author": "Paxic",
"author_id": 64457,
"author_profile": "https://Stackoverflow.com/users/64457",
"pm_score": 0,
"selected": false,
"text": "<p>Are none of its style elements being included? Is it being over ridden( they are Cascading Style Sheets)? Does it have th... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Style sheet in master page is not working for one web page of asp.net application but it works for another web page. | If you are referencing a css file from a master page you should ensure it has an absolute path, that way it will work everywhere. For example:
```
<head runat="server">
<link type="text/css" rel="stylesheet" href="~/_styles/mystylesheet.css" />
</head>
```
The important thing to note here is that the head tag ha... |
552,467 | <p>I know how to get the size (x,y) of an image</p>
<pre><code>Image.FromFile("cat.jpg").Size
</code></pre>
<p>BUT that requires loading the image from memory.</p>
<p>When I view the images in Windows Explorer it shows me the size.</p>
<ul>
<li>How do I access that size?</li>
<li>Is it reliable for all images... | [
{
"answer_id": 552491,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 2,
"selected": false,
"text": "<p>Doing this usually involves actually opening the file and reading only its header (the first few bytes) to find its format... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I know how to get the size (x,y) of an image
```
Image.FromFile("cat.jpg").Size
```
BUT that requires loading the image from memory.
When I view the images in Windows Explorer it shows me the size.
* How do I access that size?
* Is it reliable for all images? Does Windows explorer need to have 'seen' the image fir... | You can just use [`Image.FromStream(Stream, bool, bool)`](http://msdn.microsoft.com/en-us/library/21zw9ah6.aspx) with "false" 2nd and 3rd parameter to avoid loading file into memory. |
552,500 | <p>For my new asp.net application that I am developing I would like to generate an image at runtime using a webservice (return bytes), and show this as a image using Javascript (so that I can have ajax functionality.</p>
<p>Any ideas how to do this?</p>
<p>Or any ideas as to how I can generate an image at runtime, an... | [
{
"answer_id": 552519,
"author": "amazedsaint",
"author_id": 45956,
"author_profile": "https://Stackoverflow.com/users/45956",
"pm_score": 1,
"selected": false,
"text": "<p>Here is the code to have an ashx file to return the image for you.</p>\n<p>Now, add the following handler informati... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33052/"
] | For my new asp.net application that I am developing I would like to generate an image at runtime using a webservice (return bytes), and show this as a image using Javascript (so that I can have ajax functionality.
Any ideas how to do this?
Or any ideas as to how I can generate an image at runtime, and show it on my w... | Instead of having the web service put an ASHX page with the querystring parameters handling the input params.
Make sure the Response.Content type is image/png
This ASHX page will generates the image stream on the fly and send it to the requesting image object. With this there is no image file saved on the server.
[H... |
552,512 | <p>I have a huge number of files to sort all named in some terrible convention.<br>
Here are some examples: </p>
<p>(4)_mr__mcloughlin____.txt<br>
12__sir_john_farr____.txt<br>
(b)mr__chope____.txt<br>
dame_elaine_kellett-bowman____.txt<br>
dr__blackburn______.txt </p>
<p>These names are supposed to be a different ... | [
{
"answer_id": 552546,
"author": "wuputah",
"author_id": 66752,
"author_profile": "https://Stackoverflow.com/users/66752",
"pm_score": 2,
"selected": false,
"text": "<p>I've not used Perl in a while so I'm going to write this in Ruby. I will comment it to establish some pseudocode.</p>\n... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27739/"
] | I have a huge number of files to sort all named in some terrible convention.
Here are some examples:
(4)\_mr\_\_mcloughlin\_\_\_\_.txt
12\_\_sir\_john\_farr\_\_\_\_.txt
(b)mr\_\_chope\_\_\_\_.txt
dame\_elaine\_kellett-bowman\_\_\_\_.txt
dr\_\_blackburn\_\_\_\_\_\_.txt
These names are supposed to be a... | I hope I understand your question right, it's a bit ambiguous IMHO. This code is untested, but should do what I think you want.
```
use File::Copy;
sub sanatize {
local $_ = shift;
s/\b(?:dame|dr|mr|sir)\b|\d+|\(\w+\)|.txt$//g;
s/[ _]+/ /g;
s/^ | $//g;
return lc $_;
}
sub sort_files_to_dirs {
... |
552,521 | <p>I have a model Product</p>
<p>it has two fields size & colours among others</p>
<pre><code>colours = models.CharField(blank=True, null=True, max_length=500)
size = models.CharField(blank=True, null=True, max_length=500)
</code></pre>
<p>In my view I have </p>
<pre><code>current_product = Product.objects.get... | [
{
"answer_id": 552530,
"author": "ruds",
"author_id": 66509,
"author_profile": "https://Stackoverflow.com/users/66509",
"pm_score": 4,
"selected": true,
"text": "<p><code>NoneType</code> is the type that the <code>None</code> value has. You want to change the second snippet to</p>\n\n<pr... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62118/"
] | I have a model Product
it has two fields size & colours among others
```
colours = models.CharField(blank=True, null=True, max_length=500)
size = models.CharField(blank=True, null=True, max_length=500)
```
In my view I have
```
current_product = Product.objects.get(slug=title)
if len(current_product.size) != 0 :
... | `NoneType` is the type that the `None` value has. You want to change the second snippet to
```
if current_product.size: # This will evaluate as false if size is None or len(size) == 0.
blah blah
``` |
552,524 | <p>I'm writing a js script that people will add to their web site by adding a single line of code to the header or end of the body part of their HTML.</p>
<p>My question is how to do the onload right on the external js file. Will the code below work? Can't it possibly run after the onload of the document and miss the ... | [
{
"answer_id": 552598,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"http://www.w3schools.com/jsref/jsref_onload.asp\" rel=\"nofollow noreferrer\">onLoad</a> even... | 2009/02/16 | [
"https://Stackoverflow.com/questions/552524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64106/"
] | I'm writing a js script that people will add to their web site by adding a single line of code to the header or end of the body part of their HTML.
My question is how to do the onload right on the external js file. Will the code below work? Can't it possibly run after the onload of the document and miss the onload eve... | I am afraid that if you can't use jQuery or some other library you need to reproduce a way good deal of their functionality. The reason is that browsers handle the onLoad event differently.
I recommend that you download jQuery's code and see how the documentready function is implemented. |