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 |
|---|---|---|---|---|---|---|
337,090 | <p>I have created a TCP client that connects to a listening server.
We implemeted TCP keep alive also.
Some times the client crashes and core dumped.
Below are the core dump traces.</p>
<p>Problem is in linux kernel version Update 4, kernel 2.6.9-42.0.10.</p>
<p>we had two core dumps.</p>
<pre><code>(gdb) where
#0 0... | [
{
"answer_id": 337748,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 1,
"selected": false,
"text": "<p><code>_dl_sysinfo_int80</code> is just a function which does a system call into the kernel. So the core dump is happenin... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have created a TCP client that connects to a listening server.
We implemeted TCP keep alive also.
Some times the client crashes and core dumped.
Below are the core dump traces.
Problem is in linux kernel version Update 4, kernel 2.6.9-42.0.10.
we had two core dumps.
```
(gdb) where
#0 0x005e77a2 in _dl_sysinfo_int... | `_dl_sysinfo_int80` is just a function which does a system call into the kernel. So the core dump is happening on a system call (probably the one used by `connect` in the first example and `nanosleep` in the second example), probably because you are passing invalid pointers.
The invalid pointers could be because the c... |
337,103 | <p>I have a form with a few buttons which execute code when pressed like running validations on the database.</p>
<p>Some code can run for a few minutes so is there any way to show the time remaining or a message to display the % of process completed?</p>
<p>Or pop out a message when code evaluation starts and the me... | [
{
"answer_id": 337129,
"author": "Mike Powell",
"author_id": 205,
"author_profile": "https://Stackoverflow.com/users/205",
"pm_score": 0,
"selected": false,
"text": "<p>In order to do this the \"normal\" way, you'd need to run your validation in another thread and have it report its prog... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31132/"
] | I have a form with a few buttons which execute code when pressed like running validations on the database.
Some code can run for a few minutes so is there any way to show the time remaining or a message to display the % of process completed?
Or pop out a message when code evaluation starts and the message should disa... | What you are probably looking for is a "Progress Bar".
I've used the Microsoft ProgressBar control (you can find it under Insert->ActiveX Control), and it's not that hard to use. Just set the value of it to a percentage (as an integer, not a decimal).
```
'foo, being the ProgressBar
me.foo = 70 '70%
```
There is so... |
337,112 | <p>I need to round decimal numbers to six places using JavaScript, but I need to consider legacy browsers so I <a href="http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference" rel="noreferrer">can't rely on Number.toFixed</a> </p>
<blockquote>
<p>The big catch with toExponential, toFixed, and toPrecis... | [
{
"answer_id": 337139,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "<p>I think Firefox 1.5 and IE 5 are pretty much no longer used, or by a very minor quantity of people.<br>\nIt is a bit lik... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] | I need to round decimal numbers to six places using JavaScript, but I need to consider legacy browsers so I [can't rely on Number.toFixed](http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference)
>
> The big catch with toExponential, toFixed, and toPrecision is that they are fairly modern constructs no... | Try this:
```
if (!Number.prototype.toFixed)
Number.prototype.toFixed = function(precision) {
var power = Math.pow(10, precision || 0);
return String(Math.round(this * power)/power);
}
``` |
337,121 | <p>Suppose I have a class 'Application'. In order to be initialised it takes certain settings in the constructor. Let's also assume that the number of settings is so many that it's compelling to place them in a class of their own.</p>
<p>Compare the following two implementations of this scenario.</p>
<p>Implementatio... | [
{
"answer_id": 337130,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 1,
"selected": false,
"text": "<p>You might want to check out what <a href=\"http://msdn.microsoft.com/lv-lv/library/ms229042(en-us).aspx\" rel=\"nofollow ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32688/"
] | Suppose I have a class 'Application'. In order to be initialised it takes certain settings in the constructor. Let's also assume that the number of settings is so many that it's compelling to place them in a class of their own.
Compare the following two implementations of this scenario.
Implementation 1:
```
class A... | I think it's fine. This is basically the builder pattern, and using nested classes works pretty well. It also lets the builder access private members of the outer class, which can be very useful. For instance, you can have a Build method on the builder which calls a private constructor on the outer class which takes an... |
337,141 | <p>I am working with an order system that has two tables Order and OrderLine pretty standard stuff. I want to work out an order line number for the order lines with respect to the order e.g.</p>
<p>Orderid Orderlineid linenumber<br>
1 1  ... | [
{
"answer_id": 337214,
"author": "kristof",
"author_id": 3241,
"author_profile": "https://Stackoverflow.com/users/3241",
"pm_score": 3,
"selected": true,
"text": "<p>You can use something like this:</p>\n\n<pre><code>select \n ol1.orderId,\n ol1.orderLineId,\n count(*) as lineNu... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2253/"
] | I am working with an order system that has two tables Order and OrderLine pretty standard stuff. I want to work out an order line number for the order lines with respect to the order e.g.
Orderid Orderlineid linenumber
1 1 1
2 2 1
2 3 2
3 ... | You can use something like this:
```
select
ol1.orderId,
ol1.orderLineId,
count(*) as lineNumber
from
orderLine ol1
inner join orderLine ol2
on ol1.orderId = ol2.orderId
and ol1.orderLineId >= ol2.orderLineId
group by
ol1.orderId,
ol1.orderLineId
``` |
337,158 | <p>I have researched and haven't found a way to run INTERSECT and MINUS operations in MS Access. Does any way exist</p>
| [
{
"answer_id": 337199,
"author": "Kevin Fairchild",
"author_id": 3743,
"author_profile": "https://Stackoverflow.com/users/3743",
"pm_score": 2,
"selected": false,
"text": "<p>They're done through JOINs. The old fashioned way :)</p>\n\n<p>For INTERSECT, you can use an INNER JOIN. Pretty ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6613/"
] | I have researched and haven't found a way to run INTERSECT and MINUS operations in MS Access. Does any way exist | INTERSECT is an inner join. MINUS is an outer join, where you choose only the records that don't exist in the other table.
---
**INTERSECT**
```
select distinct
a.*
from
a
inner join b on a.id = b.id
```
---
**MINUS**
```
select distinct
a.*
from
a
left outer join b on a.id = b.id
where
b.id is nul... |
337,159 | <p>In an application I need to execute other programs with another user's credentials. Currently I use <strong><a href="http://msdn.microsoft.com/en-us/library/ed04yy3t.aspx" rel="nofollow noreferrer">System.Diagnostics.Process.Start</a></strong> to execute the program:</p>
<pre><code>public static Process Start(
s... | [
{
"answer_id": 337226,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.loaduserprofile.aspx\" rel=\"norefe... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999/"
] | In an application I need to execute other programs with another user's credentials. Currently I use **[System.Diagnostics.Process.Start](http://msdn.microsoft.com/en-us/library/ed04yy3t.aspx)** to execute the program:
```
public static Process Start(
string fileName,
string arguments,
string userName,
Secu... | [System.Diagnostics.ProcessStartInfo.LoadUserProfile](http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.loaduserprofile.aspx) |
337,165 | <p>This code is executed by many way. When it's executed by the form button it works (the button start a thread and in the loop it call this method = it works). BUT it doesn't work when I have a call to that method from my BackgroundWorker in the form. </p>
<p>With the following code:</p>
<pre><code>private void resi... | [
{
"answer_id": 337171,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>You need to return at the end of the if block - otherwise you'll resize it in the right thread, and then do it in the ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21386/"
] | This code is executed by many way. When it's executed by the form button it works (the button start a thread and in the loop it call this method = it works). BUT it doesn't work when I have a call to that method from my BackgroundWorker in the form.
With the following code:
```
private void resizeThreadSafe(int widt... | You need to return at the end of the if block - otherwise you'll resize it in the right thread, and then do it in the wrong thread as well.
In other words (if you'd cut and paste the code instead of a picture, this would have been easier...)
```
private void resizeThreadSafe(int width, int height)
{
if (this.form... |
337,175 | <p>I was once given this task to do in an RDBMS:</p>
<p>Given tables customer, order, orderlines and product. Everything done with the usual fields and relationships, with a comment memo field on the orderline table.</p>
<p>For one customer retrieve a list of all products that customer has ever ordered with product n... | [
{
"answer_id": 337195,
"author": "GalacticCowboy",
"author_id": 29638,
"author_profile": "https://Stackoverflow.com/users/29638",
"pm_score": 2,
"selected": false,
"text": "<p>In most RDBMS you have the option of temporary tables or local table variables that you can use to break up a ta... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37771/"
] | I was once given this task to do in an RDBMS:
Given tables customer, order, orderlines and product. Everything done with the usual fields and relationships, with a comment memo field on the orderline table.
For one customer retrieve a list of all products that customer has ever ordered with product name, year of firs... | You definitely should be able to do this exercise without doing the work equivalent to a `JOIN` in application code, i.e. by fetching all rows from both orderlines and products and iterating through them. You don't have to be an SQL wizard to do that one. **`JOIN` is to SQL what a loop is to a procedural language** -- ... |
337,181 | <p>I need to create a rectangle bubble with rounded corners with text inside, like a cartoon speech bubble. I need the bubble to expand horizontally and vertically depending on the size of the text it contain. I would like the speech arrow and the radius of the rounded corners to remain constant.</p>
<p>I could simpl... | [
{
"answer_id": 337604,
"author": "Bogdan Varlamov",
"author_id": 42573,
"author_profile": "https://Stackoverflow.com/users/42573",
"pm_score": 1,
"selected": false,
"text": "<p>The rounded corners can just be a Border with Corner Aliasing set.</p>\n\n<p>The constant / speech arrow can be... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42826/"
] | I need to create a rectangle bubble with rounded corners with text inside, like a cartoon speech bubble. I need the bubble to expand horizontally and vertically depending on the size of the text it contain. I would like the speech arrow and the radius of the rounded corners to remain constant.
I could simply use a pat... | Use this XAML, You can create a PopUp or a ContentControl and can give this Grid as the control template on it to get a consistent look
```
<Grid x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Rectangle Fill="#FF686868" ... |
337,183 | <p>I'd like to output html controls using xslt, but I need to be able to name the controls so that I can get at them when the form posts back.</p>
<p>I'd like to be able to name the radio button <code>"action_" + _case_id</code>.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="te... | [
{
"answer_id": 337227,
"author": "Artur...",
"author_id": 41465,
"author_profile": "https://Stackoverflow.com/users/41465",
"pm_score": 0,
"selected": false,
"text": "<pre><code><?xml version=\"1.0\" encoding=\"utf-8\"?>\n<?xml-stylesheet type=\"text/xsl\" href=\"data.xsl\"?>... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42697/"
] | I'd like to output html controls using xslt, but I need to be able to name the controls so that I can get at them when the form posts back.
I'd like to be able to name the radio button `"action_" + _case_id`.
```
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="data.xsl"?>
<NewDataSet>
... | Use:
**```
<input type="radio" name="{concat('action_', /*/*/*/case_id)}"
value="No" checked ="true"/>
```**
In case your xml document changes it may be necessary to substitute the "\*" chars above with more detailed location steps. |
337,186 | <p>My if statement is always evaluating to false and not entering the <code><span></code> block. Because of which, I'm not able to get the value of "index" in the if condition, I've tried every thing appending index with # and %. Can anybody suggest the solution?</p>
<pre><code><c:forEach var="index" begin="1... | [
{
"answer_id": 337212,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "<p>The test value isn't evaluatable, it's just a string to the page. </p>\n\n<p>Edit, you have you use strut's syntax. </p>\... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28557/"
] | My if statement is always evaluating to false and not entering the `<span>` block. Because of which, I'm not able to get the value of "index" in the if condition, I've tried every thing appending index with # and %. Can anybody suggest the solution?
```
<c:forEach var="index" begin="1" end="<%=a%>" step="1">
<s:if... | got it actully it is some conflict in the tags
it should be like
```
<c:forEach var="index" begin="1" end="<%=a%>" step="1" varStatus="status">
<c:choose>
<c:when test="${page_id==index}">
<span class="curre... |
337,223 | <p>Disclaimer: I'm fairly new to python!</p>
<p>If I want all the lines of a file until (edit: and including) the line containing some string <code>stopterm</code>, is there a way of using the list syntax for it? I was hoping there would be something like:</p>
<pre><code>usefullines = [line for line in file until sto... | [
{
"answer_id": 337247,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 1,
"selected": false,
"text": "<h2>Forget this</h2>\n<p>Leaving the answer, but marking it community. See <a href=\"https://stackoverflow.com/users/... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36537/"
] | Disclaimer: I'm fairly new to python!
If I want all the lines of a file until (edit: and including) the line containing some string `stopterm`, is there a way of using the list syntax for it? I was hoping there would be something like:
```
usefullines = [line for line in file until stopterm in line]
```
For now, I'... | ```
from itertools import takewhile
usefullines = takewhile(lambda x: not re.search(stopterm, x), lines)
from itertools import takewhile
usefullines = takewhile(lambda x: stopterm not in x, lines)
```
Here's a way that keeps the stopterm line:
```
def useful_lines(lines, stopterm):
for line in lines:
if... |
337,237 | <p>I need the current user and the domain. I am using a VB 6 application. </p>
<p>Thanks</p>
| [
{
"answer_id": 337262,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 5,
"selected": true,
"text": "<p>One way would be to ask the environment:</p>\n\n<pre><code>Dim UserName As String\nDim UserDomain As String\nUserName ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1154/"
] | I need the current user and the domain. I am using a VB 6 application.
Thanks | One way would be to ask the environment:
```
Dim UserName As String
Dim UserDomain As String
UserName = Environ("USERNAME")
UserDomain = Environ("USERDOMAIN")
```
(Works on Windows NT and up only, obviously.) |
337,239 | <p>In C#, if I declare an auto-implemented property, why do I have to declare BOTH the get and set part? </p>
<p>i.e.</p>
<pre><code>public string ThisWorks { get; set; }
public string ThisDoesnt { get; }
</code></pre>
<p>Isn't this just syntactic sugar - i.e. the compiler inserts a private field for the property?... | [
{
"answer_id": 337246,
"author": "stusmith",
"author_id": 6604,
"author_profile": "https://Stackoverflow.com/users/6604",
"pm_score": 6,
"selected": true,
"text": "<p>If you didn't have a setter - then how would you ever set the property?</p>\n\n<p>Incidentally, you can specify the acces... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | In C#, if I declare an auto-implemented property, why do I have to declare BOTH the get and set part?
i.e.
```
public string ThisWorks { get; set; }
public string ThisDoesnt { get; }
```
Isn't this just syntactic sugar - i.e. the compiler inserts a private field for the property? So why the problem?
Curious. | If you didn't have a setter - then how would you ever set the property?
Incidentally, you can specify the accessibility, eg:
```
public string Foo
{
get;
private set;
}
``` |
337,240 | <p>I'm using a table adapter in Visual Studio to make a query to a stored procedure in my SQL Server 2005 database. When I make the call via my website application it returns nothing. When I make the same call via SQL Server Manager it returns the expected data.</p>
<p>I put a breakpoint on the call to the adapter's... | [
{
"answer_id": 337311,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 1,
"selected": false,
"text": "<p>Dates need to have quotes around them in SQL else they don't work. </p>\n"
},
{
"answer_id": 337380,
"autho... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1491425/"
] | I'm using a table adapter in Visual Studio to make a query to a stored procedure in my SQL Server 2005 database. When I make the call via my website application it returns nothing. When I make the same call via SQL Server Manager it returns the expected data.
I put a breakpoint on the call to the adapter's `getData` m... | Use Sql Profiler to see how the sql sent to sql server actually looks like. This has helped me many times. |
337,293 | <p>I need to edit (using javascript) an SVG document embedded in an html page.</p>
<p>When the SVG is loaded, I can access the dom of the SVG and its elements. But I am not able to know if the SVG dom is ready or not, so I cant' perform default actions on the SVG when the html page is loaded.</p>
<p>To access the SVG... | [
{
"answer_id": 337319,
"author": "Mocky",
"author_id": 3211,
"author_profile": "https://Stackoverflow.com/users/3211",
"pm_score": -1,
"selected": false,
"text": "<p>You can assign an onload event handler to an element within your SVG document and have it call a javascript function in th... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36587/"
] | I need to edit (using javascript) an SVG document embedded in an html page.
When the SVG is loaded, I can access the dom of the SVG and its elements. But I am not able to know if the SVG dom is ready or not, so I cant' perform default actions on the SVG when the html page is loaded.
To access the SVG dom, I use this ... | You could try polling every so often.
```
function checkReady() {
var svg = document.getElementById("chart").getSVGDocument();
if (svg == null) {
setTimeout("checkReady()", 300);
} else {
...
}
}
``` |
337,300 | <p>We need to validate an user on Microsoft's Active Directory using Delphi 7, what is the best way to do that?</p>
<p>We can have two scenarios: the user inputs its network username and password, where the username may include the domain, and we check on active directory if it is a valid, active user. Or we get the c... | [
{
"answer_id": 337379,
"author": "Mohammed Nasman",
"author_id": 24462,
"author_profile": "https://Stackoverflow.com/users/24462",
"pm_score": 1,
"selected": false,
"text": "<p>Google for using ADSI with Delphi, you can find some articles talking about that</p>\n\n<p><a href=\"http://www... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We need to validate an user on Microsoft's Active Directory using Delphi 7, what is the best way to do that?
We can have two scenarios: the user inputs its network username and password, where the username may include the domain, and we check on active directory if it is a valid, active user. Or we get the current log... | Here's a unit we wrote and use. Simple and gets the job done.
```
unit ADSI;
interface
uses
SysUtils, Classes, ActiveX, Windows, ComCtrls, ExtCtrls, ActiveDs_TLB,
adshlp, oleserver, Variants;
type
TPassword = record
Expired: boolean;
NeverExpires: boolean;
CannotChange: boolean;
end;
type
TADSI... |
337,304 | <p>Which Eclipse files is it appropriate to put under source control, aside from the sources obviously?</p>
<p>In my project, specifically, I'm wondering about:</p>
<blockquote>
<p>.metadata/*<br>
project-dir/.project<br>
project-dir/.classpath<br>
project-dir/.settings/* </p>
</blockquote>
<p>If there are ... | [
{
"answer_id": 337317,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 8,
"selected": true,
"text": "<p>Metadata should not be managed in source control. They contain mostly data relevant to <em>your</em> workspace.</p>\n\n<p>The... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4893/"
] | Which Eclipse files is it appropriate to put under source control, aside from the sources obviously?
In my project, specifically, I'm wondering about:
>
> .metadata/\*
>
> project-dir/.project
>
> project-dir/.classpath
>
> project-dir/.settings/\*
>
>
>
If there are any of these for which it depend... | Metadata should not be managed in source control. They contain mostly data relevant to *your* workspace.
The only exception is the `.launch` XML files (launcher definition).
They are found in
```
[eclipse-workspace]\.metadata\.plugins\org.eclipse.debug.core\.launches
```
And they should be copied into your project... |
337,327 | <p>What is the C# optimised version of the following, without using .Net's Timespan or DateTime. How would I NUnit test it? </p>
<pre><code>TimeSpan ts = Date1 - Date2;
int numberOfDays = ts.Days;
</code></pre>
| [
{
"answer_id": 337350,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 5,
"selected": true,
"text": "<p>It has to do with demand-paging. Your app cannot be run directly from the SD-card, as SD is not executable media so it h... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11757/"
] | What is the C# optimised version of the following, without using .Net's Timespan or DateTime. How would I NUnit test it?
```
TimeSpan ts = Date1 - Date2;
int numberOfDays = ts.Days;
``` | It has to do with demand-paging. Your app cannot be run directly from the SD-card, as SD is not executable media so it has to be pulled into RAM to run. Windows CE doesn't typically have a whole lot of RAM, so the loader doesn't pull your entire application into RAM to run. Sure, your heaps and stacks will be in RAM, b... |
337,330 | <p>I'm hopeless at Javascript. This is what I have:</p>
<pre><code><script type="text/javascript">
function beginrefresh(){
//set the id of the target object
var marquee = document.getElementById("marquee_text");
if(marquee.scrollLeft >= marquee.scrollWidth - parseInt(marquee.sty... | [
{
"answer_id": 337413,
"author": "GeekyMonkey",
"author_id": 29900,
"author_profile": "https://Stackoverflow.com/users/29900",
"pm_score": 5,
"selected": true,
"text": "<p>Here is a jQuery plugin with a lot of features:</p>\n\n<p><a href=\"http://jscroller2.markusbordihn.de/example/image... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31168/"
] | I'm hopeless at Javascript. This is what I have:
```
<script type="text/javascript">
function beginrefresh(){
//set the id of the target object
var marquee = document.getElementById("marquee_text");
if(marquee.scrollLeft >= marquee.scrollWidth - parseInt(marquee.style.width)) {
... | Here is a jQuery plugin with a lot of features:
<http://jscroller2.markusbordihn.de/example/image-scroller-windiv/>
And this one is "silky smooth"
<http://remysharp.com/2008/09/10/the-silky-smooth-marquee/> |
337,333 | <p>I want to insert a new row into an Access database. I'm looking at doing something like: </p>
<pre><code>oConnection = new Connection("connectionstring")
oTable = oCennection.table("Orders")
oRow = oTable.NewRow
oRow.field("OrderNo")=21
oRow.field("Customer") = "ABC001"
oTable.insert
</code></pre>
<p>Which seems t... | [
{
"answer_id": 337461,
"author": "Stefan",
"author_id": 19307,
"author_profile": "https://Stackoverflow.com/users/19307",
"pm_score": 3,
"selected": true,
"text": "<p>This is one way: </p>\n\n<pre><code>cn = New OleDbConnection(\"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\emp.mdb;... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726/"
] | I want to insert a new row into an Access database. I'm looking at doing something like:
```
oConnection = new Connection("connectionstring")
oTable = oCennection.table("Orders")
oRow = oTable.NewRow
oRow.field("OrderNo")=21
oRow.field("Customer") = "ABC001"
oTable.insert
```
Which seems to be a sensible way of doi... | This is one way:
```
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\emp.mdb;")
cn.Open()
str = "insert into table1 values(21,'ABC001')"
cmd = New OleDbCommand(str, cn)
cmd.ExecuteNonQuery
```
I would make a dataset, add a tableadapter connected to the Access database, then let the tablead... |
337,334 | <p>I am trying to send an anonymous object over a web service. Is there anyway I can do this without manually creating a class and casting it to that class? Currently its throwing an exception saying Anonymous object could not be serialized.</p>
<pre><code>// Some code has been removed here to simplify the example.
[W... | [
{
"answer_id": 337366,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>Anonymous type are meant to be used for simple projections of very loosely coupled data, used only within a method. If... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I am trying to send an anonymous object over a web service. Is there anyway I can do this without manually creating a class and casting it to that class? Currently its throwing an exception saying Anonymous object could not be serialized.
```
// Some code has been removed here to simplify the example.
[WebMethod(Enabl... | Anonymous type are meant to be used for simple projections of very loosely coupled data, used only within a method. If it makes sense for a web method to return data of a type, it really should be decently encapsulated. In other words, even if you *can* find a way to return an instance of an anonymous type from a web m... |
337,352 | <p>Is there a way to 'pre-build' a snippet of HTML before adding it to the DOM?</p>
<p>For example:</p>
<pre><code>$mysnippet.append("<h1>hello</h1>");
$mysnippet.append("<h1>world</h1>");
$("destination").append($mysnippet);
</code></pre>
<p>where <strong>$mysnippet</strong> doesnt exist in ... | [
{
"answer_id": 337385,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 6,
"selected": true,
"text": "<p>Yes pretty much exactly how you have done it</p>\n\n<p>Some extension of this...</p>\n\n<pre><code>$('<div>').attr('i... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39655/"
] | Is there a way to 'pre-build' a snippet of HTML before adding it to the DOM?
For example:
```
$mysnippet.append("<h1>hello</h1>");
$mysnippet.append("<h1>world</h1>");
$("destination").append($mysnippet);
```
where **$mysnippet** doesnt exist in the DOM. I'd like to dynamically build up some lumps of html and then ... | Yes pretty much exactly how you have done it
Some extension of this...
```
$('<div>').attr('id', 'yourid').addClass('yourclass').append().append()...
```
and then finally
```
.appendTo($("#parentid"));
``` |
337,355 | <p>I need to bitwise shift a value 64 times in JavaScript. But JavaScript starts rounding after <code>32</code>.</p>
<p>For example:</p>
<pre><code>for(var j = 0; j < 64; j++)
{
mask = mask << 1;
console.log(mask);
}
</code></pre>
<p>This prints value from <code>0</code> to <code>1073741824</code> b... | [
{
"answer_id": 337407,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 4,
"selected": false,
"text": "<p>JavaScript stores all its numbers as 64 bit initally, but as soon as you start using bitwise operators the interpreter con... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42846/"
] | I need to bitwise shift a value 64 times in JavaScript. But JavaScript starts rounding after `32`.
For example:
```
for(var j = 0; j < 64; j++)
{
mask = mask << 1;
console.log(mask);
}
```
This prints value from `0` to `1073741824` but then rounds of and starts printing `0`. | "In Java, the bitwise operators work with integers. JavaScript doesn't have integers. It only has double precision floating-point numbers. So, the bitwise operators convert their number operands into integers, do their business, and then convert them back. In most languages, these operators are very close to the hardwa... |
337,364 | <p>I am maintaining an application that was written in Visual Basic 6.0 and makes use of the several OLE controls with <code>Excel.Sheet.8</code> class objects. Several users are getting the following error when they reach a point in code that attempts to manipulate the excel objects. </p>
<blockquote>
<p>Run-time e... | [
{
"answer_id": 337464,
"author": "Ricardo Villamil",
"author_id": 19314,
"author_profile": "https://Stackoverflow.com/users/19314",
"pm_score": 2,
"selected": true,
"text": "<p>I believe you can interact with Lotus Notes from .net and query it to get you the xyz@xyz.xyz addresses in the ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10007/"
] | I am maintaining an application that was written in Visual Basic 6.0 and makes use of the several OLE controls with `Excel.Sheet.8` class objects. Several users are getting the following error when they reach a point in code that attempts to manipulate the excel objects.
>
> Run-time error '91': Object variable or W... | I believe you can interact with Lotus Notes from .net and query it to get you the xyz@xyz.xyz addresses in the group. I'm not very familiar with it but you could start here:
* <http://www.codeproject.com/KB/cs/lotusnoteintegrator.aspx>
* [IBM Lotus Notes and .NET](http://www.ibm.com/developerworks/lotus/library/domino... |
337,419 | <p>What is the best way to ascertain the length (in characters) of the longest element in an array?</p>
<p>I need to find the longest element in an array of option values for a select box so that I can set the width dynamically.</p>
| [
{
"answer_id": 337435,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 1,
"selected": false,
"text": "<p>There are two ways of doing that :</p>\n\n<ol>\n<li>Iterate over the whole array and keep the maximum element size ;</li>\n... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69346/"
] | What is the best way to ascertain the length (in characters) of the longest element in an array?
I need to find the longest element in an array of option values for a select box so that I can set the width dynamically. | This returns the key of the longest value and can also give you the value itself
```
function array_longest_value( $array, &$val = null )
{
$val = null;
$result = null;
foreach( array_keys( $array ) as $i )
{
$l = strlen( $array[ $i ] );
if ( $l > $result )
{
$resul... |
337,422 | <p>How to UDP Broadcast with C in Linux?</p>
| [
{
"answer_id": 337437,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 2,
"selected": false,
"text": "<p>Typically using the Berkeley sockets API, to <code>sendto()</code> one or more datagrams to a known <a href=\"http://en.... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1100/"
] | How to UDP Broadcast with C in Linux? | In many IP stack, such as Linux, this code does not work. Your socket must have broadcast permissions. Try this:
```
bcast_sock = socket(AF_INET, SOCK_DGRAM, 0);
int broadcastEnable=1;
int ret=setsockopt(bcast_sock, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
/* Add other code, sockaddr, sen... |
337,449 | <p>I need to declare an array of pointers to functions like so:</p>
<pre><code>extern void function1(void);
extern void function2(void);
...
void (*MESSAGE_HANDLERS[])(void) = {
function1,
function2,
...
};
</code></pre>
<p>However, I want the the array to be declared as constant -- both the data in the arr... | [
{
"answer_id": 337477,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 4,
"selected": false,
"text": "<p>In situations like this, do a <code>typedef</code> to name your function signature, that makes it far simpler:</p>\n\n<p... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1491/"
] | I need to declare an array of pointers to functions like so:
```
extern void function1(void);
extern void function2(void);
...
void (*MESSAGE_HANDLERS[])(void) = {
function1,
function2,
...
};
```
However, I want the the array to be declared as constant -- both the data in the array and the pointer to the ... | There is a technique to remember how to build such type. First try to read pointers starting from their name and read from right to left.
How to declare that stuff without help?
---------------------------------------
### Arrays
```
T t[5];
```
is an *array of 5 T*. To make T a function type, you write the return... |
337,459 | <p>In every form we derive from <code>FormBaseControl</code>, we have the following code. I'm sure there is a better way to type the controller object than this, but at the moment we have it included in every page. In the example below, <code>base.Controller</code> is of type <code>BaseController</code>, from which <... | [
{
"answer_id": 337489,
"author": "FerranB",
"author_id": 40441,
"author_profile": "https://Stackoverflow.com/users/40441",
"pm_score": 0,
"selected": false,
"text": "<p>I think there is a design problem here. </p>\n\n<p>Are you sure that MyController is needed to be ExportControler (or a... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] | In every form we derive from `FormBaseControl`, we have the following code. I'm sure there is a better way to type the controller object than this, but at the moment we have it included in every page. In the example below, `base.Controller` is of type `BaseController`, from which `ExportController` derives. I find dupl... | Can you not use a generic class to fix this?
I.e. instead of:
```
private ExportController MyController
{
get { return base.Controller as ExportController; }
}
```
in the derived class.
Put:
```
protected T MyController
{
get { return this as T; }
}
```
in the base class, and turn the bas... |
337,476 | <p>I have a <code>ListBox</code> where the number of items is added based on and integer property set by a user. The items are created from a <code>ControlTemplate</code> resource that which is comprised of a Label and a <code>TextBox</code> inside of a <code>DockPanel</code>. The label is not data bound but I would li... | [
{
"answer_id": 337489,
"author": "FerranB",
"author_id": 40441,
"author_profile": "https://Stackoverflow.com/users/40441",
"pm_score": 0,
"selected": false,
"text": "<p>I think there is a design problem here. </p>\n\n<p>Are you sure that MyController is needed to be ExportControler (or a... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42858/"
] | I have a `ListBox` where the number of items is added based on and integer property set by a user. The items are created from a `ControlTemplate` resource that which is comprised of a Label and a `TextBox` inside of a `DockPanel`. The label is not data bound but I would like for it to have somewhat dynamic content base... | Can you not use a generic class to fix this?
I.e. instead of:
```
private ExportController MyController
{
get { return base.Controller as ExportController; }
}
```
in the derived class.
Put:
```
protected T MyController
{
get { return this as T; }
}
```
in the base class, and turn the bas... |
337,479 | <p>MySQL ResultSets are by default retrieved completely from the server before any work can be done. In cases of huge result sets this becomes unusable. I would like instead to actually retrieve the rows one by one from the server.</p>
<p>In Java, following the instructions <a href="http://dev.mysql.com/doc/refman/5.1... | [
{
"answer_id": 337560,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": false,
"text": "<p>Did you try this version of fetchone? Or something different?</p>\n\n<pre><code>row = cursor.fetchone() \nwhile row is ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7581/"
] | MySQL ResultSets are by default retrieved completely from the server before any work can be done. In cases of huge result sets this becomes unusable. I would like instead to actually retrieve the rows one by one from the server.
In Java, following the instructions [here](http://dev.mysql.com/doc/refman/5.1/en/connecto... | I think you have to connect passing `cursorclass = MySQLdb.cursors.SSCursor`:
```
MySQLdb.connect(user="user",
passwd="password",
db="mydb",
cursorclass = MySQLdb.cursors.SSCursor
)
```
The default cursor fetches all the data at once, even if you d... |
337,482 | <p>I want to display print dialog in servlet/jsp. Below is my code:</p>
<pre><code>DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet () ;
PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService defaultService = P... | [
{
"answer_id": 337502,
"author": "Loki",
"author_id": 39057,
"author_profile": "https://Stackoverflow.com/users/39057",
"pm_score": 1,
"selected": false,
"text": "<p>You need to be aware that it is not the client that is executing your code here. It's the server.</p>\n\n<p>You'll have to... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to display print dialog in servlet/jsp. Below is my code:
```
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet () ;
PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService defaultService = PrintServiceLoo... | You need to be aware that it is not the client that is executing your code here. It's the server.
You'll have to make a javascript function for that to work. |
337,519 | <p>I moved an ex-site based on joomla to wordpress. Import worked fine but the problem is that the old links don't work anymore.
Because there is only 50 or so articles, i thought will be a good idea to put a rule for each post (in .htaccess).</p>
<p>Well... Not always things are like you want, so redirects dont work ... | [
{
"answer_id": 338092,
"author": "jlleblanc",
"author_id": 586,
"author_profile": "https://Stackoverflow.com/users/586",
"pm_score": 2,
"selected": true,
"text": "<p>Since the conversion of your site over to Wordpress is relatively new, is there anything preventing you from using the old... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23810/"
] | I moved an ex-site based on joomla to wordpress. Import worked fine but the problem is that the old links don't work anymore.
Because there is only 50 or so articles, i thought will be a good idea to put a rule for each post (in .htaccess).
Well... Not always things are like you want, so redirects dont work at all :(
... | Since the conversion of your site over to Wordpress is relatively new, is there anything preventing you from using the old Joomla! ID's in your WP database table? This would allow you to use a regex fairly easily.
Another option would be to create a separate PHP script that handles the Joomla! URLs then redirects to t... |
337,522 | <p>I'm trying to write a windows batch file that can delete files from subdirectories. I would rather not hard code the directory structure in, so I can use this process with other projects.</p>
<ul>
<li>I need to delete files of X type,</li>
<li>I have the parent folder <code>C:\MyProject</code>,</li>
<li>There are ... | [
{
"answer_id": 337542,
"author": "Pedrin",
"author_id": 36183,
"author_profile": "https://Stackoverflow.com/users/36183",
"pm_score": 6,
"selected": true,
"text": "<p>Actually you can use the standard del command:</p>\n\n<pre><code>c:\ncd MyProject\ndel /S *.type\n</code></pre>\n\n<p>Whe... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34183/"
] | I'm trying to write a windows batch file that can delete files from subdirectories. I would rather not hard code the directory structure in, so I can use this process with other projects.
* I need to delete files of X type,
* I have the parent folder `C:\MyProject`,
* There are Y subfolders `C:\MyProject\?`,
* There a... | Actually you can use the standard del command:
```
c:
cd MyProject
del /S *.type
```
Where type is the extension you want to delete and the /S parameter will check in all subfolders of MyProject. |
337,581 | <p>In the case when I want to check, if a certain entry in the database exists I have two options.</p>
<p>I can create an sql query using COUNT() and then check, if the result is >0...</p>
<p>...or I can just retrieve the record(s) and then count the number of rows in the returned rowset. For example with $result->nu... | [
{
"answer_id": 337593,
"author": "Matt McClellan",
"author_id": 35218,
"author_profile": "https://Stackoverflow.com/users/35218",
"pm_score": 2,
"selected": false,
"text": "<p>YMMV, but I suspect that if you are only checking for existence, and don't need to use the retrieved data in any... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11995/"
] | In the case when I want to check, if a certain entry in the database exists I have two options.
I can create an sql query using COUNT() and then check, if the result is >0...
...or I can just retrieve the record(s) and then count the number of rows in the returned rowset. For example with $result->num\_rows;
What's ... | ```
SELECT 1
FROM (SELECT 1) t
WHERE EXISTS( SELECT * FROM foo WHERE id = 42 )
```
Just tested, works fine on MySQL v5
COUNT(\*) is generally less efficient if:
1. you can have duplicates (because the
DBMS will have to exhaustively
search all of the records/indexes to
give you the exact answer) or
2. have NUL... |
337,588 | <p>According to <a href="http://www.builderau.com.au/program/perl/soa/Obtain-user-group-and-process-information-in-Perl/0,339028313,339222142,00.htm" rel="nofollow noreferrer">this site</a> I can simply write </p>
<pre><code>$user = getlogin();
</code></pre>
<p>but the group handling functions seem not to be able to ... | [
{
"answer_id": 337640,
"author": "fB.",
"author_id": 36218,
"author_profile": "https://Stackoverflow.com/users/36218",
"pm_score": 4,
"selected": true,
"text": "<p>No need to parse system files, on an UNIX-like operating system I would use the builtin interfaces to the getpwuid and getgr... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/686/"
] | According to [this site](http://www.builderau.com.au/program/perl/soa/Obtain-user-group-and-process-information-in-Perl/0,339028313,339222142,00.htm) I can simply write
```
$user = getlogin();
```
but the group handling functions seem not to be able to accept a username/userid as a parameter. Should I really iterat... | No need to parse system files, on an UNIX-like operating system I would use the builtin interfaces to the getpwuid and getgrgid system calls:
```
use strict;
use warnings;
# use $< for the real uid and $> for the effective uid
my ($user, $passwd, $uid, $gid ) = getpwuid $< ;
my $group = getgrgid $gid ;
printf "user... |
337,598 | <p>Ok, bear with me guys and girls as I'm learning. Here's my question.</p>
<p>I can't figure out why I can't override a method from a parent class. Here's the code from the base class (yes, I pilfered the java code from an OOP book and am trying to rewrite it in C#).</p>
<pre><code>using System;
public class Mood... | [
{
"answer_id": 337622,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 1,
"selected": false,
"text": "<pre><code>public class SadObject: MoodyObject\n {\n override String getMood()\n</code></pre>\n"
},
{
... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38317/"
] | Ok, bear with me guys and girls as I'm learning. Here's my question.
I can't figure out why I can't override a method from a parent class. Here's the code from the base class (yes, I pilfered the java code from an OOP book and am trying to rewrite it in C#).
```
using System;
public class MoodyObject
{
protected... | In C# methods are not virtual by default, so if you design some method as overridable, you should specify it as virtual:
```
class Base
{
protected virtual string GetMood() {...}
}
```
Second, you have to specify that you are going to override method from base class in derived class.
```
class Derived : Base
{
... |
337,608 | <p>I am trying to find a way to get the source code for (user defined) PHP functions in a string.</p>
<p>For normal code this is easy, using reflection I can find the file and line numbers where the function is defined; then I can open the file and read the function source code.</p>
<p>This will not work if a functio... | [
{
"answer_id": 815664,
"author": "Tyler",
"author_id": 65977,
"author_profile": "https://Stackoverflow.com/users/65977",
"pm_score": 3,
"selected": false,
"text": "<p>It always gives them in order.</p>\n\n<p>So I think you'd have to find the distance (or time) between each pair of points... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30700/"
] | I am trying to find a way to get the source code for (user defined) PHP functions in a string.
For normal code this is easy, using reflection I can find the file and line numbers where the function is defined; then I can open the file and read the function source code.
This will not work if a function is defined in e... | There is an option in Google Maps API DirectionsRequest called optimizeWaypoints, which should do what you want. This can only handle up to 8 waypoints, though.
Alternatively, there is an open source (MIT license) library that you can use with the Google Maps API to get an optimal (up to 15 locations) or pretty close ... |
337,631 | <p>Say I have a bitmap image, is it possible to iterate through all the individual bytes in the image? If yes, how?</p>
| [
{
"answer_id": 337651,
"author": "Filip Ekberg",
"author_id": 39106,
"author_profile": "https://Stackoverflow.com/users/39106",
"pm_score": 3,
"selected": false,
"text": "<p>I found this: <a href=\"http://channel9.msdn.com/forums/TechOff/108813-Bitmap-to-byte-array/\" rel=\"nofollow nore... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | Say I have a bitmap image, is it possible to iterate through all the individual bytes in the image? If yes, how? | I found this: <http://channel9.msdn.com/forums/TechOff/108813-Bitmap-to-byte-array/>
Saying that you could use a Memorystream and the .Save method it'd look like this:
```
System.Drawing.Bitmap bmp = GetTheBitmap();
System.IO.MemoryStream stream = new System.IO.MemoryStream();
bmp.Save(stream, System.Drawing.Imaging.... |
337,649 | <p>I'm building a <a href="https://en.wikipedia.org/wiki/Windows_Forms" rel="nofollow noreferrer">Windows Forms</a> form in C# with various elements in a panel that starts out either invisible, disabled, or set to null (labels, combo boxes, grids, etc.). As the user goes through and makes choices, these elements are po... | [
{
"answer_id": 337679,
"author": "GWLlosa",
"author_id": 18071,
"author_profile": "https://Stackoverflow.com/users/18071",
"pm_score": 1,
"selected": false,
"text": "<p>You could try calling this.InitializeComponent(), which may do the trick. Alternately, if your application has a 'Dire... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28939/"
] | I'm building a [Windows Forms](https://en.wikipedia.org/wiki/Windows_Forms) form in C# with various elements in a panel that starts out either invisible, disabled, or set to null (labels, combo boxes, grids, etc.). As the user goes through and makes choices, these elements are populated, selected, etc.
The idea is to ... | Simply remove the panel from the form and create the new one.
Sample:
```
Panel CreatePanelWithDynamicControls() {
Panel ret = new Panel();
ret.Dock = DockStyle.Fill;
// Some logic, which initializes content of panel
return ret;
}
void InitializeDynamicControls() {
this.Controls.Clear();
Pan... |
337,656 | <p>I set up a simple event handler as mentioned <a href="https://stackoverflow.com/questions/49510/how-do-you-set-your-cocoa-application-as-the-default-web-browser">here</a>, but it appears that the selector isn't called. I put the code in my AppDelegate class and wired up the delegate in IB. Tried putting in some NSLo... | [
{
"answer_id": 338952,
"author": "Boaz Stuller",
"author_id": 1464654,
"author_profile": "https://Stackoverflow.com/users/1464654",
"pm_score": 0,
"selected": false,
"text": "<p>The big question is: Where are you calling NSAppleEventManager's -setEventHandler:...? You need to call this ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34386/"
] | I set up a simple event handler as mentioned [here](https://stackoverflow.com/questions/49510/how-do-you-set-your-cocoa-application-as-the-default-web-browser), but it appears that the selector isn't called. I put the code in my AppDelegate class and wired up the delegate in IB. Tried putting in some NSLog()s and break... | Well, I can't help but notice that you're `-init` method is mis-declared. If should have return type `id` and have a `return self;` at the end.
```
- (id)init
{
self = [super init];
if (self) {
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(getUrl:withReplyEv... |
337,664 | <p>I'm designing an algorithm to do the following: Given array <code>A[1... n]</code>, for every <code>i < j</code>, find all inversion pairs such that <code>A[i] > A[j]</code>. I'm using merge sort and copying array A to array B and then comparing the two arrays, but I'm having a difficult time seeing how I can ... | [
{
"answer_id": 337773,
"author": "mbillard",
"author_id": 810,
"author_profile": "https://Stackoverflow.com/users/810",
"pm_score": 1,
"selected": false,
"text": "<p>The easy O(n^2) answer is to use nested for-loops and increment a counter for every inversion</p>\n\n<pre><code>int counte... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27884/"
] | I'm designing an algorithm to do the following: Given array `A[1... n]`, for every `i < j`, find all inversion pairs such that `A[i] > A[j]`. I'm using merge sort and copying array A to array B and then comparing the two arrays, but I'm having a difficult time seeing how I can use this to find the number of inversions.... | So here is O(n log n) solution in java.
```
long merge(int[] arr, int[] left, int[] right) {
int i = 0, j = 0;
long count = 0;
while (i < left.length || j < right.length) {
if (i == left.length) {
arr[i+j] = right[j];
j++;
} else if (j == right.length) {
... |
337,669 | <p>When adding a bookmark or favorite the browser uses the TITLE tag of the page to automatically populate the title of the bookmark. However, my web pages use SEO-friendly titles which are not really user-friendly. Is there a method to override the title when the browser makes a bookmark?</p>
<p>I am aware that I can... | [
{
"answer_id": 337692,
"author": "Filip Ekberg",
"author_id": 39106,
"author_profile": "https://Stackoverflow.com/users/39106",
"pm_score": 3,
"selected": true,
"text": "<p>I can't see how that would be possible. The browser takes the Title loaded, which is the Title displayed on the top... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188/"
] | When adding a bookmark or favorite the browser uses the TITLE tag of the page to automatically populate the title of the bookmark. However, my web pages use SEO-friendly titles which are not really user-friendly. Is there a method to override the title when the browser makes a bookmark?
I am aware that I can create a ... | I can't see how that would be possible. The browser takes the Title loaded, which is the Title displayed on the top of the page. When saving a bookmark, it doesnt go through the code. It just adds the URL and takes the site Title.
You could check if the "bookmark"-pressing triggers a javascript event, though, i think ... |
337,688 | <p>Does python have the ability to create dynamic keywords?</p>
<p>For example:</p>
<pre><code>qset.filter(min_price__usd__range=(min_price, max_price))
</code></pre>
<p>I want to be able to change the <strong>usd</strong> part based on a selected currency.</p>
| [
{
"answer_id": 337714,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 7,
"selected": true,
"text": "<p>Yes, It does. Use <code>**kwargs</code> in a function definition.</p>\n\n<p>Example:</p>\n\n<pre><code>def f(**kwargs):\n p... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42876/"
] | Does python have the ability to create dynamic keywords?
For example:
```
qset.filter(min_price__usd__range=(min_price, max_price))
```
I want to be able to change the **usd** part based on a selected currency. | Yes, It does. Use `**kwargs` in a function definition.
Example:
```
def f(**kwargs):
print kwargs.keys()
f(a=2, b="b") # -> ['a', 'b']
f(**{'d'+'e': 1}) # -> ['de']
```
But why do you need that? |
337,691 | <p>I'm attempting to find the best methodology for finding a specific pattern and then
replace the ending portion of the pattern. Here is a quick example (in C#):</p>
<p>//Find any year value starting with a bracket or underscore</p>
<pre><code>string patternToFind = "[[_]2007";
Regex yearFind = new Regex(patternT... | [
{
"answer_id": 337709,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 3,
"selected": false,
"text": "<p>Your pattern does not work as described: as described you need to start with \"<code>\\[|_</code>\" (the pipe means OR... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm attempting to find the best methodology for finding a specific pattern and then
replace the ending portion of the pattern. Here is a quick example (in C#):
//Find any year value starting with a bracket or underscore
```
string patternToFind = "[[_]2007";
Regex yearFind = new Regex(patternToFind);
```
//I want... | Your pattern does not work as described: as described you need to start with "`\[|_`" (the pipe means OR), and the solution to your actual problem is *regex grouping*. Surround the part of the pattern you are interested in in brackets "(" and ")" and you can access them in the replacer.
You therefore need a pattern li... |
337,694 | <p>On a page I want to dynamically list years and all the months in each year so an archive for each month can be viewed. I want to show the current year first but the current year may not be over yet so I only want to show the months that have passed, and the current month. Then I want all years and all months in the ... | [
{
"answer_id": 337712,
"author": "Filip Ekberg",
"author_id": 39106,
"author_profile": "https://Stackoverflow.com/users/39106",
"pm_score": 0,
"selected": false,
"text": "<p>PHP has a Date() function and an mktime function, you can use these to compare dates and to create dates out of st... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183/"
] | On a page I want to dynamically list years and all the months in each year so an archive for each month can be viewed. I want to show the current year first but the current year may not be over yet so I only want to show the months that have passed, and the current month. Then I want all years and all months in the pas... | ```
$current_year = date('Y');
$months = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
$month_names = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
// Loop through all the months and create an array up to and including the current month... |
337,704 | <p>How do I parameterize a query containing an <code>IN</code> clause with a variable number of arguments, like this one?</p>
<pre><code>SELECT * FROM Tags
WHERE Name IN ('ruby','rails','scruffy','rubyonrails')
ORDER BY Count DESC
</code></pre>
<p>In this query, the number of arguments could be anywhere from 1 to 5.... | [
{
"answer_id": 337752,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 7,
"selected": false,
"text": "<p>You can pass the parameter as a string</p>\n\n<p>So you have the string </p>\n\n<pre><code>DECLARE @tags\n\nSET @ta... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1/"
] | How do I parameterize a query containing an `IN` clause with a variable number of arguments, like this one?
```
SELECT * FROM Tags
WHERE Name IN ('ruby','rails','scruffy','rubyonrails')
ORDER BY Count DESC
```
In this query, the number of arguments could be anywhere from 1 to 5.
I would prefer not to use a dedicat... | Here's a quick-and-dirty technique I have used:
```
SELECT * FROM Tags
WHERE '|ruby|rails|scruffy|rubyonrails|'
LIKE '%|' + Name + '|%'
```
So here's the C# code:
```
string[] tags = new string[] { "ruby", "rails", "scruffy", "rubyonrails" };
const string cmdText = "select * from tags where '|' + @tags + '|' like '... |
337,713 | <p>I'm developing an ASP.NET 2.0 application that includes Crystal Reports (version 10, included with VS 2005). Originally, the reports were working properly, both when run from my machine using the ASP.NET development web server, and also when deployed to an IIS server.</p>
<p>I made some changes to the reports and ... | [
{
"answer_id": 337752,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 7,
"selected": false,
"text": "<p>You can pass the parameter as a string</p>\n\n<p>So you have the string </p>\n\n<pre><code>DECLARE @tags\n\nSET @ta... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17777/"
] | I'm developing an ASP.NET 2.0 application that includes Crystal Reports (version 10, included with VS 2005). Originally, the reports were working properly, both when run from my machine using the ASP.NET development web server, and also when deployed to an IIS server.
I made some changes to the reports and re-deployed... | Here's a quick-and-dirty technique I have used:
```
SELECT * FROM Tags
WHERE '|ruby|rails|scruffy|rubyonrails|'
LIKE '%|' + Name + '|%'
```
So here's the C# code:
```
string[] tags = new string[] { "ruby", "rails", "scruffy", "rubyonrails" };
const string cmdText = "select * from tags where '|' + @tags + '|' like '... |
337,732 | <p>I am looking to persistently display a game score in an iPhone app using cocos2d. Going off the code that cocos2d shows the FPS the app is running at:</p>
<pre><code>-(void) showFPS
{
frames++;
accumDt += dt;
if ( accumDt > 0.1) {
frameRate = frames/accumDt;
frames = 0;
acc... | [
{
"answer_id": 339276,
"author": "user21293",
"author_id": 21293,
"author_profile": "https://Stackoverflow.com/users/21293",
"pm_score": 3,
"selected": false,
"text": "<p>For anyone who might be interested, I ended up using a cocos2d Label as so:</p>\n\n<pre><code>scoreLabel = [Label lab... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21293/"
] | I am looking to persistently display a game score in an iPhone app using cocos2d. Going off the code that cocos2d shows the FPS the app is running at:
```
-(void) showFPS
{
frames++;
accumDt += dt;
if ( accumDt > 0.1) {
frameRate = frames/accumDt;
frames = 0;
accumDt = 0;
}
... | Try using LabelAtlas instead. It is faster (it consumes much less CPU).
See the AtlasDemo that comes with the cocos2d distribution to see how to use it. |
337,734 | <p>Is it possible to merge elements using XSLT.</p>
<p>If I have the following XML</p>
<pre><code><data>
<item column="left" value="1" />
<item column="left" value="2" />
<item column="right" value="3" />
<item column="left" value="4" />
<item column="right" value="5" />
<item c... | [
{
"answer_id": 337800,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": -1,
"selected": false,
"text": "<p>You would use the element and attribute tags...</p>\n\n<pre><code><xsl:element name=\"item\">\n <xsl:attr... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/274/"
] | Is it possible to merge elements using XSLT.
If I have the following XML
```
<data>
<item column="left" value="1" />
<item column="left" value="2" />
<item column="right" value="3" />
<item column="left" value="4" />
<item column="right" value="5" />
<item column="right" value="6" />
<item column="right" value="7" />... | This transformation:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="data">
<xsl:variable name="vNumLeft" select="count(item[@column='left'])"/>
<data>
<xsl:apply-templates select... |
337,737 | <p>I'm using PUT and DELETE more and more w/ my ajax work and wanted to see if it would be a "bad idea" to add these verbs to the .aspx application extension in IIS.</p>
| [
{
"answer_id": 337800,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": -1,
"selected": false,
"text": "<p>You would use the element and attribute tags...</p>\n\n<pre><code><xsl:element name=\"item\">\n <xsl:attr... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] | I'm using PUT and DELETE more and more w/ my ajax work and wanted to see if it would be a "bad idea" to add these verbs to the .aspx application extension in IIS. | This transformation:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="data">
<xsl:variable name="vNumLeft" select="count(item[@column='left'])"/>
<data>
<xsl:apply-templates select... |
337,739 | <p>In rails I want to log some information in a different log file and not the standard development.log or production.log. I want to do this logging from a model class.</p>
| [
{
"answer_id": 337971,
"author": "Thiago Arrais",
"author_id": 17801,
"author_profile": "https://Stackoverflow.com/users/17801",
"pm_score": 9,
"selected": true,
"text": "<p>You can create a Logger object yourself from inside any model. Just pass the file name to the constructor and use ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29653/"
] | In rails I want to log some information in a different log file and not the standard development.log or production.log. I want to do this logging from a model class. | You can create a Logger object yourself from inside any model. Just pass the file name to the constructor and use the object like the usual Rails `logger`:
```
class User < ActiveRecord::Base
def my_logger
@@my_logger ||= Logger.new("#{Rails.root}/log/my.log")
end
def before_save
my_logger.info("Creatin... |
337,744 | <p>I'm importing Brazilian stock market data to a SQL Server database. Right now I have a table with price information from three kind of assets: stocks, options and forwards. I'm still in 2006 data and the table has over half million records. I have more 12 years of data to import so the table will exceed a million re... | [
{
"answer_id": 337776,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>A million records really isn't that big. It does sound like it's taking too long to search though - is the column you... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18623/"
] | I'm importing Brazilian stock market data to a SQL Server database. Right now I have a table with price information from three kind of assets: stocks, options and forwards. I'm still in 2006 data and the table has over half million records. I have more 12 years of data to import so the table will exceed a million recor... | 1. At 1 million records, I wouldn't consider this a particularly large table needing unusual optimization techniques such as splitting the table up, denormalizing, etc. But those decisions will come when you've tried all the normal means that don't affect your ability to use standard query techniques.
>
> Now, second... |
337,760 | <p>I am trying to create an array starting with today and going back the last 30 days with PHP and I am having trouble. I can estimate but I don’t know a good way of doing it and taking into account the number of days in the previous month etc. Does anyone have a good solution? I can’t get close but I need to make su... | [
{
"answer_id": 337794,
"author": "ThoKra",
"author_id": 38254,
"author_profile": "https://Stackoverflow.com/users/38254",
"pm_score": 5,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code><?php \n$d = array();\nfor($i = 0; $i < 30; $i++) \n $d[] = date(\"d\", strtotim... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to create an array starting with today and going back the last 30 days with PHP and I am having trouble. I can estimate but I don’t know a good way of doing it and taking into account the number of days in the previous month etc. Does anyone have a good solution? I can’t get close but I need to make sure it... | Try this:
```
<?php
$d = array();
for($i = 0; $i < 30; $i++)
$d[] = date("d", strtotime('-'. $i .' days'));
?>
``` |
337,766 | <p>Due to the way my serverside script outputs I receive multiple JSON objects. <code>{jsonhere}{jsonhere1}{jsonhere2}{jsonhere3} etc..</code> They aren't seperated by anything. If I would do a split based <code>}{</code> I would lose those brackets. So is there an outerloop I can put over the regular <code>$.each</cod... | [
{
"answer_id": 337806,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 1,
"selected": false,
"text": "<p>this isn't JSON.</p>\n\n<p>jQuery interprets JSON the lazy way, calling eval() and hoping there's no 'real' code in ther... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Due to the way my serverside script outputs I receive multiple JSON objects. `{jsonhere}{jsonhere1}{jsonhere2}{jsonhere3} etc..` They aren't seperated by anything. If I would do a split based `}{` I would lose those brackets. So is there an outerloop I can put over the regular `$.each` loop to make this work?
Thank yo... | Rough algorithm:
```
Define a stack
Define an array
LOOP on each character in the string
IF the top item of the stack is a single or double quote THEN
LOOP through each character until you find a matching single or double quote, then pop it from the stack.
ELSE
IF "{", push onto the stack
... |
337,769 | <p>I use the following statement prepared and bound in ODBC:</p>
<pre><code>SELECT (CASE profile WHEN ? THEN 1 ELSE 2 END) AS profile_order
FROM engine_properties;
</code></pre>
<p>Executed in an ODBC 3.0 connection to an Oracle 10g database in AL32UTF8 charset, even after binding to a wchar_t string using <code>SQL... | [
{
"answer_id": 337806,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 1,
"selected": false,
"text": "<p>this isn't JSON.</p>\n\n<p>jQuery interprets JSON the lazy way, calling eval() and hoping there's no 'real' code in ther... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31423/"
] | I use the following statement prepared and bound in ODBC:
```
SELECT (CASE profile WHEN ? THEN 1 ELSE 2 END) AS profile_order
FROM engine_properties;
```
Executed in an ODBC 3.0 connection to an Oracle 10g database in AL32UTF8 charset, even after binding to a wchar\_t string using `SQLBindParameter(SQL_C_WCHAR)`, i... | Rough algorithm:
```
Define a stack
Define an array
LOOP on each character in the string
IF the top item of the stack is a single or double quote THEN
LOOP through each character until you find a matching single or double quote, then pop it from the stack.
ELSE
IF "{", push onto the stack
... |
337,781 | <p>In ASP.NET, the tilde (~) is treated as a token in URLs and treats paths prefixed with that as relative to the application root. This is well-known functionality.</p>
<p>In MOSS, there are other tokens, such as ~sitecollection/mypath... which behaves in a similar way, but treats the path as relative to the site col... | [
{
"answer_id": 338199,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know for sure - but I'd bet that code is buried in one of the SharePoint HTTPModules or HTTPHandlers that run fo... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67/"
] | In ASP.NET, the tilde (~) is treated as a token in URLs and treats paths prefixed with that as relative to the application root. This is well-known functionality.
In MOSS, there are other tokens, such as ~sitecollection/mypath... which behaves in a similar way, but treats the path as relative to the site collection ro... | It may not be the only place, but [SPUtility.GetServerRelativeUrlFromPrefixedUrl()](http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.getserverrelativeurlfromprefixedurl.aspx) will parse URLs with ~site and ~sitecollection. MOSS also provides [SPUrlExpressionBuilder](http://msdn.microsoft... |
337,784 | <p>I have created a mutli-column combobox in VB.net 2008 using windows forms 2.0. I am having trouble accessing data once selected to use in the remainder of the form. There does not seem to be a selected event to use in conjunction with the winform 2.0 combobox.</p>
<p>Does anyone have any experience using winforms 2... | [
{
"answer_id": 338199,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know for sure - but I'd bet that code is buried in one of the SharePoint HTTPModules or HTTPHandlers that run fo... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5578/"
] | I have created a mutli-column combobox in VB.net 2008 using windows forms 2.0. I am having trouble accessing data once selected to use in the remainder of the form. There does not seem to be a selected event to use in conjunction with the winform 2.0 combobox.
Does anyone have any experience using winforms 2.0? Also I... | It may not be the only place, but [SPUtility.GetServerRelativeUrlFromPrefixedUrl()](http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.getserverrelativeurlfromprefixedurl.aspx) will parse URLs with ~site and ~sitecollection. MOSS also provides [SPUrlExpressionBuilder](http://msdn.microsoft... |
337,797 | <p>When we use datatable.newrow command, a new empty row added to bottom of rows. However I want newrow to added to top of datatable. How can I make it?</p>
| [
{
"answer_id": 337818,
"author": "Nick DeVore",
"author_id": 1380,
"author_profile": "https://Stackoverflow.com/users/1380",
"pm_score": 7,
"selected": true,
"text": "<p>You use the NewRow to create a row with the same columns. To actually get it into the DataTable, you've got to do</p>... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439507/"
] | When we use datatable.newrow command, a new empty row added to bottom of rows. However I want newrow to added to top of datatable. How can I make it? | You use the NewRow to create a row with the same columns. To actually get it into the DataTable, you've got to do
```
myDataTable.Rows.InsertAt(myDataRow, 0);
```
Where 0 is the index you want to insert it at. |
337,803 | <p>I have a ComponentResourceKey defined in my resource dictionary like this:</p>
<pre><code><Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:Resources}, ResourceId=BaseControlStyle}" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,4,0,0" />
</Style&g... | [
{
"answer_id": 337838,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 3,
"selected": true,
"text": "<p>I figured it out. </p>\n\n<pre><code>myTextBox.Style = \n Application.Current.TryFindResource(Resources.BaseControl... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | I have a ComponentResourceKey defined in my resource dictionary like this:
```
<Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:Resources}, ResourceId=BaseControlStyle}" TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="4,4,0,0" />
</Style>
```
I have a static class t... | I figured it out.
```
myTextBox.Style =
Application.Current.TryFindResource(Resources.BaseControlStyleKey)
as Style;
``` |
337,849 | <p>I am trying to make a small, data-driven widget that is populated with data from a database on the fly. I can load it initially just fine, but when the index of an ASP DropDownMenu is changed, the widget returns a 404.</p>
<p>This could be a symptom of how I am using the Javascript, or how I am using the ASP. I h... | [
{
"answer_id": 337881,
"author": "Gavin Miller",
"author_id": 33226,
"author_profile": "https://Stackoverflow.com/users/33226",
"pm_score": 1,
"selected": false,
"text": "<p>If the postback is returning 404, I'd look at the url that you're sending the postback to. </p>\n\n<pre>http://we... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to make a small, data-driven widget that is populated with data from a database on the fly. I can load it initially just fine, but when the index of an ASP DropDownMenu is changed, the widget returns a 404.
This could be a symptom of how I am using the Javascript, or how I am using the ASP. I honestly don'... | If the postback is returning 404, I'd look at the url that you're sending the postback to.
```
http://webwidgetstest.reeceandnichols.com/rDeskWidgetMLSt.aspx?agentname=jendene
``` |
337,856 | <p>I have an Asp.net Mvc site where I want to give a separate access and user interface to different clients like:
<a href="http://company1.mysite.com" rel="nofollow noreferrer">http://company1.mysite.com</a><br>
<a href="http://company2.mysite.com" rel="nofollow noreferrer">http://company2.mysite.com</a><br>
<a href="... | [
{
"answer_id": 337862,
"author": "Eduardo Molteni",
"author_id": 2385,
"author_profile": "https://Stackoverflow.com/users/2385",
"pm_score": 0,
"selected": false,
"text": "<p>You have to check the incoming URL and serve different CSS files for each one. You can use background images if y... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1929/"
] | I have an Asp.net Mvc site where I want to give a separate access and user interface to different clients like:
<http://company1.mysite.com>
<http://company2.mysite.com>
<http://company3.mysite.com>
Each client will have a different ui but practically same functionality (or with some features disabled).
I'd ... | There are a number of things you can do. The first level, as already mentioned is to use a different CSS file. You can dynamically put in a different path to your CSS file, by creating a Helper method. So it would be used something like this:
```
<link href="<%=AppHelper.GetCSSPath("mysite.css")%>" rel="stylesheet" ty... |
337,857 | <p>I'm just finishing up a computer architecture course this semester where, among other things, we've been dabbling in MIPS assembly and running it in the MARS simulator. Today, out of curiosity, I started messing around with NASM on my Ubuntu box, and have basically just been piecing things together from tutorials an... | [
{
"answer_id": 337872,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>Without knowing the actual answer or having the time to look it up, I'm guessing that the environment variables get stored i... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42891/"
] | I'm just finishing up a computer architecture course this semester where, among other things, we've been dabbling in MIPS assembly and running it in the MARS simulator. Today, out of curiosity, I started messing around with NASM on my Ubuntu box, and have basically just been piecing things together from tutorials and g... | Without knowing the actual answer or having the time to look it up, I'm guessing that the environment variables get stored in memory after the command line arguments. Your code is simply buffer overflowing into the environment variable strings and printing them too.
This actually makes sense, since the command line ar... |
337,863 | <p>I run a subprocess using:</p>
<pre><code> p = subprocess.Popen("subprocess",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
</code></pre>
<p>This subprocess could either exit immediately with an error on stderr, or kee... | [
{
"answer_id": 337912,
"author": "grieve",
"author_id": 34329,
"author_profile": "https://Stackoverflow.com/users/34329",
"pm_score": 4,
"selected": false,
"text": "<p>Have you tried using the Popen.Poll() method. You could just do this:</p>\n\n<pre><code>p = subprocess.Popen(\"subproces... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I run a subprocess using:
```
p = subprocess.Popen("subprocess",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
```
This subprocess could either exit immediately with an error on stderr, or keep running. I want to detec... | Have you tried using the Popen.Poll() method. You could just do this:
```
p = subprocess.Popen("subprocess",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
time.sleep(SECONDS_TO_WAIT)
retcode = p.poll()
if retcode is not None:
# pr... |
337,868 | <p>In short, I'd like to learn/develop an elegant method to save a binary tree to disk (a general tree, not necessarily a BST). Here is the description of my problem:</p>
<p>I'm implementing a game of "20-questions". I've written a binary tree whose internal nodes are questions and leaves are answers. The left chil... | [
{
"answer_id": 337874,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 3,
"selected": false,
"text": "<p>I would do a Level-order traversal. That is to say you are basically doing a <a href=\"http://en.wikipedia.org/wik... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42897/"
] | In short, I'd like to learn/develop an elegant method to save a binary tree to disk (a general tree, not necessarily a BST). Here is the description of my problem:
I'm implementing a game of "20-questions". I've written a binary tree whose internal nodes are questions and leaves are answers. The left child of a node i... | You can store it recursively:
```
void encodeState(OutputStream out,Node n) {
if(n==null) {
out.write("[null]");
} else {
out.write("{");
out.write(n.nodeDetails());
encodeState(out, n.yesNode());
encodeState(out, n.noNode());
out.writ... |
337,870 | <p>I have some Python code that works correctly when I use python.exe to run it, but fails if I use pythonw.exe.</p>
<pre>
def runStuff(commandLine):
outputFileName = 'somefile.txt'
outputFile = open(outputFileName, "w")
try:
result = subprocess.call(commandLine, shell=True, st... | [
{
"answer_id": 337990,
"author": "Piotr Lesnicki",
"author_id": 38796,
"author_profile": "https://Stackoverflow.com/users/38796",
"pm_score": 4,
"selected": true,
"text": "<p><code>sys.stdin</code> and <code>sys.stdout</code> handles are invalid because pythonw does not provide console s... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11677/"
] | I have some Python code that works correctly when I use python.exe to run it, but fails if I use pythonw.exe.
```
def runStuff(commandLine):
outputFileName = 'somefile.txt'
outputFile = open(outputFileName, "w")
try:
result = subprocess.call(commandLine, shell=True, stdout=out... | `sys.stdin` and `sys.stdout` handles are invalid because pythonw does not provide console support as it runs as a deamon, so default arguments of `subprocess.call()` are failing.
Deamon programs close stdin/stdout/stderr purposedly and use logging instead, so that you have to manage this yourself: I would suggest to u... |
337,878 | <p>Using instance methods as callbacks for event handlers changes the scope of <code>this</code> from <em>"My instance"</em> to <em>"Whatever just called the callback"</em>. So my code looks like this</p>
<pre><code>function MyObject() {
this.doSomething = function() {
...
}
var self = this
$('#foobar').b... | [
{
"answer_id": 337923,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I think it actually depends on what are you going to do inside your <code>doSomething</code> function. If you are going to ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/407880/"
] | Using instance methods as callbacks for event handlers changes the scope of `this` from *"My instance"* to *"Whatever just called the callback"*. So my code looks like this
```
function MyObject() {
this.doSomething = function() {
...
}
var self = this
$('#foobar').bind('click', function(){
self.doSom... | This question is not specific to jQuery, but specific to JavaScript in general. The core problem is how to "channel" a variable in embedded functions. This is the example:
```
var abc = 1; // we want to use this variable in embedded functions
function xyz(){
console.log(abc); // it is available here!
function qwe... |
337,891 | <p>I've a couple of extension methods I've been developing for a couple of projects, they currently rely heavily on some AJAX to make bits and pieces work. The problem is that they require copying and pasting JavaScript files to the project you want to use it in.</p>
<p>As this JavaScript file only needs to be used on... | [
{
"answer_id": 337923,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I think it actually depends on what are you going to do inside your <code>doSomething</code> function. If you are going to ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5791/"
] | I've a couple of extension methods I've been developing for a couple of projects, they currently rely heavily on some AJAX to make bits and pieces work. The problem is that they require copying and pasting JavaScript files to the project you want to use it in.
As this JavaScript file only needs to be used once (all in... | This question is not specific to jQuery, but specific to JavaScript in general. The core problem is how to "channel" a variable in embedded functions. This is the example:
```
var abc = 1; // we want to use this variable in embedded functions
function xyz(){
console.log(abc); // it is available here!
function qwe... |
337,903 | <p>exampl:</p>
<pre><code>new Thread(new Runnable() {
public void run() {
while(condition) {
*code that must not be interrupted*
*some more code*
}
}
}).start();
SomeOtherThread.start();
YetAntherThread.start();
</code></pre>
<p>How can you ensure that <em>code that must not be interrupted... | [
{
"answer_id": 337920,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 0,
"selected": false,
"text": "<p>Best halfway solution would be to synchronize all threads on some common object so that no other threads are runnabl... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | exampl:
```
new Thread(new Runnable() {
public void run() {
while(condition) {
*code that must not be interrupted*
*some more code*
}
}
}).start();
SomeOtherThread.start();
YetAntherThread.start();
```
How can you ensure that *code that must not be interrupted* won't be interrupted? | You can't - at least not with normal Java, running on a normal, non-real-time operating system. Even if other threads don't interrupt yours, other *processes* might well do so. Basically you won't be able to guarantee that you get a CPU all to yourself until you're done. If you want this sort of guarantee you should us... |
337,918 | <p>I have a nightly batch job that can tell if it has failed. I want it to send me an email, possibly with an attachment when it does. </p>
<p>How can I send an email from a Windows Batch (.bat) file?</p>
| [
{
"answer_id": 337955,
"author": "Svante Svenson",
"author_id": 19707,
"author_profile": "https://Stackoverflow.com/users/19707",
"pm_score": 3,
"selected": true,
"text": "<p>If the SMTP-server that is a part of IIS is installed, you could use the Echo command to write a file to the pick... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20553/"
] | I have a nightly batch job that can tell if it has failed. I want it to send me an email, possibly with an attachment when it does.
How can I send an email from a Windows Batch (.bat) file? | If the SMTP-server that is a part of IIS is installed, you could use the Echo command to write a file to the pickup folder, and it'll get sent.
```
echo From: test@example.com>tmp.txt
echo To: test@example.com>>tmp.txt
echo Subject: hello>>tmp.txt
echo.>>tmp.txt
echo Hello world>>tmp.txt
copy tmp.txt \Inetpub\mailroot... |
337,986 | <p>I am from a c# background and am converting a vb.net windows forms app to c#.
I have a windows form called associateForm.
In code the developer references associate form like so:-</p>
<pre><code>Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles... | [
{
"answer_id": 337999,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 4,
"selected": true,
"text": "<p>VB.Net for .Net 2.0 and later has something called default form instances. When you define a form, you get an autom... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35441/"
] | I am from a c# background and am converting a vb.net windows forms app to c#.
I have a windows form called associateForm.
In code the developer references associate form like so:-
```
Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles EMS.MouseDoub... | VB.Net for .Net 2.0 and later has something called default form instances. When you define a form, you get an automatic instance of the form with the same name as the type. |
338,007 | <p>I have a listview with a DataTemplate that has a ComboBox. I want the ComboBox to look flat like a label until the user actually wants to change the value. I had the example below working before, but I changed things around a bit, and now it doesn't work anymore and I'm not sure why. </p>
<p>The IsMouseOver propert... | [
{
"answer_id": 338023,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 0,
"selected": false,
"text": "<p>Usually when your are having issues with Mouse events firing correctly it's due to the background missing. If the element... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42911/"
] | I have a listview with a DataTemplate that has a ComboBox. I want the ComboBox to look flat like a label until the user actually wants to change the value. I had the example below working before, but I changed things around a bit, and now it doesn't work anymore and I'm not sure why.
The IsMouseOver property does not... | I took the code you provided, supplied some data for the collections, and it worked just like you wanted it to. I would suggest using [Snoop](http://blois.us/Snoop/) to look to see if there are any other elements consuming the events you expect the ListView to handle. |
338,009 | <p>I get the correct results (nov and dec data) when I run a query in the Data tab of a report that I built in SQL Server Reporting Services. When I preview the report I get old data from October. It doesn't make any sense to me. I'm not sure whats going on. Note: the data is in Oracle.</p>
<p>Here's the date filter... | [
{
"answer_id": 338707,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Is there anything different regarding the dataset's parameters? Do report parameters feed the dataset at all? If so what ar... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I get the correct results (nov and dec data) when I run a query in the Data tab of a report that I built in SQL Server Reporting Services. When I preview the report I get old data from October. It doesn't make any sense to me. I'm not sure whats going on. Note: the data is in Oracle.
Here's the date filter I'm using
... | SSRS caches data locally for use by the designer. The cached data is only updated if the developer previews the report in VS.NET using a different set of parameters, which in your case never happens because the report has no parameters.
To allow SSRS to refresh the cached data, navigate to the directory which contains... |
338,026 | <p>I want to read a string value from the registry and concatenate it with another certain string. I'm calling RegQueryValueEx() , like this: </p>
<pre><code>Dim lResult As Long
Dim sLength As Long
Dim sString As String
sString = Space$(256)
sLength = 256
lResult = RegQueryValueEx(hKey, "MyKey", 0, REG_SZ, ByVal sSt... | [
{
"answer_id": 338055,
"author": "nobody",
"author_id": 19405,
"author_profile": "https://Stackoverflow.com/users/19405",
"pm_score": 1,
"selected": false,
"text": "<p>Precedence issue, maybe? How about trying:</p>\n\n<pre><code>MsgBox(sString & \"blah-blah-blah\")\n</code></pre>\n\n... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to read a string value from the registry and concatenate it with another certain string. I'm calling RegQueryValueEx() , like this:
```
Dim lResult As Long
Dim sLength As Long
Dim sString As String
sString = Space$(256)
sLength = 256
lResult = RegQueryValueEx(hKey, "MyKey", 0, REG_SZ, ByVal sString, sLength)... | There is probably a null-character in the string, because VB strings store the length of the string in memory just before the contents of the string. In your case that length is 256. When you load the content using RegQueryValueEx, it null-terminates the string (C-style), but does not change its indicated length, so in... |
338,037 | <p>I know that using <code>ls -l "directory/directory/filename"</code> tells me the permissions of a file. How do I do the same on a directory?</p>
<p>I could obviously use <code>ls -l</code> on the directory higher in the hierarchy and then just scroll till I find it but it's such a pain. If I use <code>ls -l</code> ... | [
{
"answer_id": 338041,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 9,
"selected": false,
"text": "<p>Here is the short answer:</p>\n\n<pre><code>$ ls -ld directory\n</code></pre>\n\n<p>Here's what it does:... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42228/"
] | I know that using `ls -l "directory/directory/filename"` tells me the permissions of a file. How do I do the same on a directory?
I could obviously use `ls -l` on the directory higher in the hierarchy and then just scroll till I find it but it's such a pain. If I use `ls -l` on the actual directory, it gives the permi... | Here is the short answer:
```
$ ls -ld directory
```
Here's what it does:
```
-d, --directory
list directory entries instead of contents, and do not dereference symbolic links
```
You might be interested in [*manpages*](http://en.wikipedia.org/wiki/Manpage). That's where all people in here get their nice answ... |
338,044 | <p>Say I have two tables, a master list of students containing personal info, and a list of student enrollments in classes. The two tables share a common column, which is a string uniquely identifying the student, but it is not the primary key. </p>
<p>Say I want to display all the enrollments on a page, along with so... | [
{
"answer_id": 338165,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": 3,
"selected": false,
"text": "<p>Ideally, Rails is expecting the following columns:</p>\n\n<pre><code>Student table:\n- id\n\nEnrollment table:\n- stu... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42914/"
] | Say I have two tables, a master list of students containing personal info, and a list of student enrollments in classes. The two tables share a common column, which is a string uniquely identifying the student, but it is not the primary key.
Say I want to display all the enrollments on a page, along with some of the ... | Yes ActiveRecord will manage the relationships for you, but you can also specify the join when searching for a condition in the relationship. For example:
```
User.find(:all, :joins => :phone_numbers, :conditions => { :phone_numbers => {:name => 'business'} })
```
Note though using a hash for the conditional declara... |
338,050 | <p>I am using SubSonic 2.1 Final but having problems running "Version" with the SubCommander. I think this problem began when I installed SQL Server 2008 on my local machine and removed 2005.</p>
<p>This is the error I get:</p>
<pre><code>ERROR: Trying to execute Version
Error Message: System.IO.FileNotFoundException... | [
{
"answer_id": 341820,
"author": "Yitzchok",
"author_id": 5723,
"author_profile": "https://Stackoverflow.com/users/5723",
"pm_score": 1,
"selected": false,
"text": "<p>You probably have to compile SubCommander with the SqlServer 2008 version of Microsoft.SqlServer.Management.Smo dlls</p>... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33349/"
] | I am using SubSonic 2.1 Final but having problems running "Version" with the SubCommander. I think this problem began when I installed SQL Server 2008 on my local machine and removed 2005.
This is the error I get:
```
ERROR: Trying to execute Version
Error Message: System.IO.FileNotFoundException: Could not load file... | I made this work by downloading the latest source and build it on my machine. Now it works great. |
338,056 | <p>I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in multiple separate applications. I could add them to the applications' assemblies, but it's better if I compile these resources in one single assembly and have my applications reference it, right? </p>
<p>After the r... | [
{
"answer_id": 338546,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 10,
"selected": true,
"text": "<p>Check out the <a href=\"http://msdn.microsoft.com/en-us/library/aa970069(VS.85).aspx\" rel=\"noreferrer\">pack URI ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28029/"
] | I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in multiple separate applications. I could add them to the applications' assemblies, but it's better if I compile these resources in one single assembly and have my applications reference it, right?
After the resource as... | Check out the [pack URI syntax](http://msdn.microsoft.com/en-us/library/aa970069(VS.85).aspx). You want something like this:
```
<ResourceDictionary Source="pack://application:,,,/YourAssembly;component/Subfolder/YourResourceFile.xaml"/>
``` |
338,075 | <p>Why would the following query return "Error converting data type varchar to bigint"? Doesn't IsNumeric make the CAST safe? I've tried every numeric datatype in the cast and get the same "Error converting..." error. I don't believe the size of the resulting number is a problem because overflow is a different error... | [
{
"answer_id": 338098,
"author": "Kevin Fairchild",
"author_id": 3743,
"author_profile": "https://Stackoverflow.com/users/3743",
"pm_score": 3,
"selected": false,
"text": "<p>Try this and see if you still get an error...</p>\n\n<pre><code>SELECT CAST(CASE \n WHEN IsNumeric(myV... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22355/"
] | Why would the following query return "Error converting data type varchar to bigint"? Doesn't IsNumeric make the CAST safe? I've tried every numeric datatype in the cast and get the same "Error converting..." error. I don't believe the size of the resulting number is a problem because overflow is a different error.
The... | IsNumeric returns 1 if the varchar value can be converted to ANY number type. This includes int, bigint, decimal, numeric, real & float.
Scientific notation could be causing you a problem. For example:
```
Declare @Temp Table(Data VarChar(20))
Insert Into @Temp Values(NULL)
Insert Into @Temp Values('1')
Insert Into ... |
338,101 | <p>Not many are aware of this feature, but Python's functions (and methods) can have <a href="http://www.python.org/dev/peps/pep-0232/" rel="noreferrer">attributes</a>. Behold:</p>
<pre><code>>>> def foo(x):
... pass
...
>>> foo.score = 10
>>> dir(foo)
['__call__', '__class__', '__d... | [
{
"answer_id": 338145,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 8,
"selected": true,
"text": "<p>I typically use function attributes as storage for annotations. Suppose I want to write, in the style of C# (ind... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] | Not many are aware of this feature, but Python's functions (and methods) can have [attributes](http://www.python.org/dev/peps/pep-0232/). Behold:
```
>>> def foo(x):
... pass
...
>>> foo.score = 10
>>> dir(foo)
['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__', '__getattribute__', '__h... | I typically use function attributes as storage for annotations. Suppose I want to write, in the style of C# (indicating that a certain method should be part of the web service interface)
```
class Foo(WebService):
@webmethod
def bar(self, arg1, arg2):
...
```
then I can define
```
def webmethod(fun... |
338,110 | <p>My users are presented a basically a stripped down version of a spreadsheet. There are textboxes in each row in the grid. When they change a value in a textbox, I'm performing validation on their input, updating the collection that's driving the grid, and redrawing the subtotals on the page. This is all handled by ... | [
{
"answer_id": 338151,
"author": "zaratustra",
"author_id": 39702,
"author_profile": "https://Stackoverflow.com/users/39702",
"pm_score": 6,
"selected": true,
"text": "<p>Use the semaphore (let's call it StillNeedsValidating). if the SaveForm function sees the StillNeedsValidating semaph... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13412/"
] | My users are presented a basically a stripped down version of a spreadsheet. There are textboxes in each row in the grid. When they change a value in a textbox, I'm performing validation on their input, updating the collection that's driving the grid, and redrawing the subtotals on the page. This is all handled by the ... | Use the semaphore (let's call it StillNeedsValidating). if the SaveForm function sees the StillNeedsValidating semaphore is up, have it activate a second semaphore of its own (which I'll call FormNeedsSaving here) and return. When the validation function finishes, if the FormNeedsSaving semaphore is up, it calls the Sa... |
338,111 | <p>The <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx" rel="nofollow noreferrer">C# 3.0 spec</a> has the following code example in section 10.6.1.3 "Output parameters":</p>
<pre><code>using System;
class Test
{
static void SplitPath(string path, out string dir, out string name) {
int i = pa... | [
{
"answer_id": 338123,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 1,
"selected": false,
"text": "<p>What error are you getting?</p>\n\n<p>System.String has had [] accessors since .NET v1.0</p>\n"
},
{
"answ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42439/"
] | The [C# 3.0 spec](http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx) has the following code example in section 10.6.1.3 "Output parameters":
```
using System;
class Test
{
static void SplitPath(string path, out string dir, out string name) {
int i = path.Length;
while (i > 0) {
char... | It is an invalid character '–'. Change '–' to '-' |
338,116 | <p>I have an EXE loaded into a byte array, and I am trying to load it into an assembly object using Assembly.Load. I am getting errors trying to load.</p>
<p>Here is the code that is causing the exception:</p>
<pre><code>Assembly a = Assembly.Load(bin);
</code></pre>
<p>bin is my byte array, loaded from the EXE.</p... | [
{
"answer_id": 338136,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure, but because it is an EXE, it might be failing because of the unmanaged headers in the EXE?</p>\n\n<p>... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42931/"
] | I have an EXE loaded into a byte array, and I am trying to load it into an assembly object using Assembly.Load. I am getting errors trying to load.
Here is the code that is causing the exception:
```
Assembly a = Assembly.Load(bin);
```
bin is my byte array, loaded from the EXE.
**Here is the exception I am gettin... | Make sure the file you're trying to load is a .NET Managed exe/dll. |
338,164 | <p>When running get svn fetch to pull the latest new branches from the upstream svn repository I got this error:</p>
<pre><code>$ git svn fetch
fatal: failed to unpack tree object 5ecb324e8b8fcb918acb253f33edc6ce49e49e0d
read-tree 5ecb324e8b8fcb918acb253f33edc6ce49e49e0d: command returned error: 128
</code></pre>
<p>... | [
{
"answer_id": 344837,
"author": "Paul",
"author_id": 23356,
"author_profile": "https://Stackoverflow.com/users/23356",
"pm_score": 2,
"selected": false,
"text": "<p>The most likely cause for this is a file or commit (that the tree references) is corrupted or missing. Or the tree itself ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42927/"
] | When running get svn fetch to pull the latest new branches from the upstream svn repository I got this error:
```
$ git svn fetch
fatal: failed to unpack tree object 5ecb324e8b8fcb918acb253f33edc6ce49e49e0d
read-tree 5ecb324e8b8fcb918acb253f33edc6ce49e49e0d: command returned error: 128
```
Now every attempt at git s... | I had the same problem. It is due to a particular SVN revision that git-svn can't read or deal with somehow. Here is what i tried in order:
1. Rewind to a revision known to work: `git svn reset -r 42`
2. Retry the fetch: `git svn fetch` — Fetches each revision starting from 42 until the guilty one (say 50), then shows... |
338,185 | <p>I have an Excel table with several items 1, 2, 3..., each of which has subitems 1.1, 1.2, etc. I'm using the list of subitems as my key column and populating the main items using vlookups, but only showing each main item once.</p>
<pre><code>/| A | B | C |
-+---------+----------+----------+
1| I... | [
{
"answer_id": 338564,
"author": "Jon Fournier",
"author_id": 5106,
"author_profile": "https://Stackoverflow.com/users/5106",
"pm_score": 0,
"selected": false,
"text": "<p>This is possible using VBA, thought I don't know if you can do it without VBA. Basically what you would do is every... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an Excel table with several items 1, 2, 3..., each of which has subitems 1.1, 1.2, etc. I'm using the list of subitems as my key column and populating the main items using vlookups, but only showing each main item once.
```
/| A | B | C |
-+---------+----------+----------+
1| Item1 | 1.No... | Extending Jon Fournier's answer, I've changed the range calculation to look for non-blank cells and added code to turn off the warning dialog that Merge throws up. I also changed the function to Public so I could run it from the Macros dialog.
```
Public Sub AutoMerge()
Dim LastRowToMergeTo As Long
Dim i As Long
Dim ... |
338,195 | <p>According to <em>Cocoa Programming for Mac OS X, 3rd Edition,</em> on page 202 (chapter 13):</p>
<blockquote>
<p>You will be registering, reading, and
setting defaults in several classes in
your application. To make sure that
you always use the same name, you
should declare those strings in a
single fil... | [
{
"answer_id": 338214,
"author": "Grant Limberg",
"author_id": 27314,
"author_profile": "https://Stackoverflow.com/users/27314",
"pm_score": 5,
"selected": true,
"text": "<p>Global variables or a singleton will accomplish the same thing here. Both can be used to turn 'key' names in Coco... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14048/"
] | According to *Cocoa Programming for Mac OS X, 3rd Edition,* on page 202 (chapter 13):
>
> You will be registering, reading, and
> setting defaults in several classes in
> your application. To make sure that
> you always use the same name, you
> should declare those strings in a
> single file and then simply #imp... | Global variables or a singleton will accomplish the same thing here. Both can be used to turn 'key' names in Cocoa that won't throw a compiler error if it's misspelled into a compiler error. That's the main purpose. Global variables are a bit easier though seeing as it requires less typing.
Instead of doing this:
```... |
338,206 | <p>Is this functionality going to be put into a later Java version?</p>
<p>Can someone explain why I can't do this, as in, the technical way Java's <code>switch</code> statement works?</p>
| [
{
"answer_id": 338230,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 11,
"selected": true,
"text": "<p>Switch statements with <code>String</code> cases have been implemented in <a href=\"http://openjdk.java.net/projects/jdk... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14007/"
] | Is this functionality going to be put into a later Java version?
Can someone explain why I can't do this, as in, the technical way Java's `switch` statement works? | Switch statements with `String` cases have been implemented in [Java SE 7](http://openjdk.java.net/projects/jdk7/features/), at least 16 years [after they were first requested.](https://bugs.java.com/bugdatabase/view_bug.do?bug_id=1223179) A clear reason for the delay was not provided, but it likely had to do with perf... |
338,212 | <p>I've got an array of objects in json format: </p>
<pre><code>[
{
"name": "obj1",
"list": [
"elem1",
"elem2",
"elem3"
]
},
{
"name": "obj2",
"list": [
"elem4",
"elem5",
"elem6"
]
}
... | [
{
"answer_id": 338585,
"author": "user37125",
"author_id": 37125,
"author_profile": "https://Stackoverflow.com/users/37125",
"pm_score": 1,
"selected": false,
"text": "<p>This works, but it's not pure regex:</p>\n\n<pre><code>var str = '[{\"name\":\"obj1\", \"list\":[\"elem1\", \"elem2\"... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got an array of objects in json format:
```
[
{
"name": "obj1",
"list": [
"elem1",
"elem2",
"elem3"
]
},
{
"name": "obj2",
"list": [
"elem4",
"elem5",
"elem6"
]
}
]
```
Now I'... | This works, but it's not pure regex:
```
var str = '[{"name":"obj1", "list":["elem1", "elem2", "elem3"]},'
+ '{"name":"obj2", "list":["elem4", "elem5", "elem6"]}]';
str = str.replace(/"list":\[[^\]]+\]/g, function (match) {
return '"list":' + match.substring(7, match.length).replace(/([^\\])"/g, '$1');
});... |
338,225 | <p>everybody; I have this problem in asp.net, I have a page where I insert and modify data, before saving I make a validation if it passes I save the data but if not I raise an exception and show it, the function goes like this;</p>
<pre><code>protected void btnSave_Click(object sender, EventArgs e)
{
try
{
...
if(Val... | [
{
"answer_id": 338238,
"author": "nickd",
"author_id": 2373,
"author_profile": "https://Stackoverflow.com/users/2373",
"pm_score": 0,
"selected": false,
"text": "<p>Is the message saved in the viewstate of the literal?</p>\n\n<p>Explicitly set the literal text to nothing if the data is v... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1130097/"
] | everybody; I have this problem in asp.net, I have a page where I insert and modify data, before saving I make a validation if it passes I save the data but if not I raise an exception and show it, the function goes like this;
```
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
...
if(ValidData())
//... | If JSLiteral is a server side control and it's using view state. Then you'd need to clear the state of the control, when the save is succesful.
You could disable the viewstate for the control like JSLiteral.EnableViewState =false; |
338,242 | <p>I'd like to store a simple key/value string dictionary in my web config file. Visual Studio makes it easy to store a string collection(see sample below) but I'm not sure how to do it with a dictionary collection.</p>
<pre><code> <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:x... | [
{
"answer_id": 338248,
"author": "Maxime Rouiller",
"author_id": 24975,
"author_profile": "https://Stackoverflow.com/users/24975",
"pm_score": 3,
"selected": false,
"text": "<p>You would need to implement a custom section (See <a href=\"http://www.codeplex.com/csd\" rel=\"nofollow norefe... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25121/"
] | I'd like to store a simple key/value string dictionary in my web config file. Visual Studio makes it easy to store a string collection(see sample below) but I'm not sure how to do it with a dictionary collection.
```
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.... | Why reinvent the wheel? The [AppSettings](http://www.odetocode.com/Articles/345.aspx) section is designed for exactly the purpose of storing dictionary-like data in your config file.
If you don't want to put too much data in your AppSettings section, you can group your related values into their own section as follows:... |
338,251 | <p>I am trying to port some data over from my production database to my sandbox using a query like this:</p>
<pre><code>INSERT `dbsandbox`.`SomeTable`(Field1, Field2, Field3)
SELECT t.Field1, t.Field2, t.Field3
FROM `dbprod`.`SomeTable` t;
</code></pre>
<p>When I attempt this cross-database join I get the following e... | [
{
"answer_id": 338319,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 3,
"selected": false,
"text": "<p>It sounds like a permissions problem. Often user permissions are set up on a database in a database fashion, so the ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42937/"
] | I am trying to port some data over from my production database to my sandbox using a query like this:
```
INSERT `dbsandbox`.`SomeTable`(Field1, Field2, Field3)
SELECT t.Field1, t.Field2, t.Field3
FROM `dbprod`.`SomeTable` t;
```
When I attempt this cross-database join I get the following error:
ERROR 1142 (42000):... | It turns out it was a permissions problem. The source database required a password for the username I was using in order to access any tables. The target only required the username be on the localhost.
Even though I launch the MySQL client using a password every time within the context of a cross-database query anoth... |
338,253 | <p>I'm getting this worthless error in my code. it's very consistant and restarting the compiler hasn't done anything. Has anyone else ever solved this? </p>
<pre><code>while( int CharPos = _Message.Pos(_What) )
{
_Message.Insert( _With, CharPos);
_Message.Delete(CharPos + 1, 1);
}
</code></pre>
| [
{
"answer_id": 338277,
"author": "thepaulpage",
"author_id": 1161710,
"author_profile": "https://Stackoverflow.com/users/1161710",
"pm_score": 2,
"selected": true,
"text": "<p>Well... apparently the compiler breaks when you try to declare an int in the while loop's condition.</p>\n"
},... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1161710/"
] | I'm getting this worthless error in my code. it's very consistant and restarting the compiler hasn't done anything. Has anyone else ever solved this?
```
while( int CharPos = _Message.Pos(_What) )
{
_Message.Insert( _With, CharPos);
_Message.Delete(CharPos + 1, 1);
}
``` | Well... apparently the compiler breaks when you try to declare an int in the while loop's condition. |
338,258 | <p>I've got two sizing issue regarding a Window I've got. The basic layout is like this</p>
<pre><code><Window MaxHeight="{DynamicResource {x:Static SystemParameters.VirtualScreenHeight}}"
MaxWidth="{DynamicResource {x:Static SystemParameters.VirtualScreenWidth}}"
>
<StackPanel>
... | [
{
"answer_id": 338278,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 3,
"selected": true,
"text": "<p>I would recommend you to use Grid with * Lenght instead of DockPanel and StackPanel.</p>\n"
},
{
"answer_id": 338... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9970/"
] | I've got two sizing issue regarding a Window I've got. The basic layout is like this
```
<Window MaxHeight="{DynamicResource {x:Static SystemParameters.VirtualScreenHeight}}"
MaxWidth="{DynamicResource {x:Static SystemParameters.VirtualScreenWidth}}"
>
<StackPanel>
<DockPanel LastChildFill... | I would recommend you to use Grid with \* Lenght instead of DockPanel and StackPanel. |
338,263 | <p>My cygwin xterm is not responding to the keyboard.</p>
<p>I am able to run rxvt, but when I start other X applications I have the same problem.</p>
<p>From the rxvt command prompt, I get the following:</p>
<pre><code>$ xterm
xterm Xt error: Can't open display: :0
</code></pre>
<p>The contents of my XWin.0.log ar... | [
{
"answer_id": 338353,
"author": "MCS",
"author_id": 1094969,
"author_profile": "https://Stackoverflow.com/users/1094969",
"pm_score": 2,
"selected": true,
"text": "<p>See <a href=\"http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-i-cant-type-anything\" rel=\"nofollow noreferrer\">this</... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1094969/"
] | My cygwin xterm is not responding to the keyboard.
I am able to run rxvt, but when I start other X applications I have the same problem.
From the rxvt command prompt, I get the following:
```
$ xterm
xterm Xt error: Can't open display: :0
```
The contents of my XWin.0.log are:
```
$ cat XWin.0.log
Welcome to the... | See [this](http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-i-cant-type-anything).
1. First stop the server by right-clicking on the X icon in the system tray and choosing exit.
2. Run the startxwin.bat file that is located in /usr/bin. |
338,267 | <p>My application needs to set cookies for specific paths in the application. For example (in php):</p>
<pre><code>setcookie(*cookie_name*,*value*,*date*,"/subpath/subpath/unique_name");
setcookie(*cookie_name*,*value*,*date*,"/subpath/subpath/another unique name");
</code></pre>
<p>Oddly enough, the first setcookie ... | [
{
"answer_id": 338581,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 0,
"selected": false,
"text": "<p>No access to a webserver atm. You haven't tried one of these?</p>\n\n<pre><code>setcookie(*cookie_name*,*value*,*date*, \"/... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My application needs to set cookies for specific paths in the application. For example (in php):
```
setcookie(*cookie_name*,*value*,*date*,"/subpath/subpath/unique_name");
setcookie(*cookie_name*,*value*,*date*,"/subpath/subpath/another unique name");
```
Oddly enough, the first setcookie works fine. The second doe... | I see no problem with spaces in cookies.
Maybe you should check how you read back your value...
My read routine is:
```
function ReadCookie(name)
{
name += '=';
var parts = document.cookie.split(/;\s*/);
for (var i = 0; i < parts.length; i++)
{
var part = parts[i];
if (part.indexOf(name) == 0)
... |
338,269 | <p>I have an app that display's the current time when a page opens. I would like that time to update every 30 seconds. I've read about prototype's Ajax.PeriodicalUpdater and it seems to be an answer. This is how I achieve the static time display on page load with php: </p>
<pre><code> <tr>
<td>
... | [
{
"answer_id": 338364,
"author": "James Orr",
"author_id": 41457,
"author_profile": "https://Stackoverflow.com/users/41457",
"pm_score": 3,
"selected": true,
"text": "<p>Unless you want your time output to always match the timezone of the server, you could do this very quickly with a bit... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1149/"
] | I have an app that display's the current time when a page opens. I would like that time to update every 30 seconds. I've read about prototype's Ajax.PeriodicalUpdater and it seems to be an answer. This is how I achieve the static time display on page load with php:
```
<tr>
<td>
<input class="standa... | Unless you want your time output to always match the timezone of the server, you could do this very quickly with a bit of Javascript on the client side and skip contacting the server entirely.
```
<html>
<body onload="init();">
<div id=time></div>
</body>
</html>
<script type=text/javascript>
function init()
{
... |
338,271 | <pre><code>
class C {
public
T x;
};
</code></pre>
<p>Is there an elegant way for the constructor of x to know <strong>implicitly</strong> in what instance of C it is constructing?
<hr>
I've implemented such behavior with some dirty inelegant machinery. I need this for my sqlite3 wrapper. I don't lik... | [
{
"answer_id": 338297,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 3,
"selected": false,
"text": "<p>No. Objects aren't supposed to need to know where they're being used from in order to work. As far as x is concern... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12151/"
] | ```
class C {
public
T x;
};
```
Is there an elegant way for the constructor of x to know **implicitly** in what instance of C it is constructing?
---
I've implemented such behavior with some dirty inelegant machinery. I need this for my sqlite3 wrapper. I don't like all wrappers I've seen, their... | No. Objects aren't supposed to need to know where they're being used from in order to work. As far as x is concerned, it's an instance of T. That's it. It doesn't behave differently according to whether it's a member of class C, a member of class D, an automatic, a temporary, etc.
Furthermore, even if the T constructo... |
338,273 | <p>I'm just learning C with Kernighan and Ritchie's book; I'm in the basics of the fourth chapter ("Functions and Program Structure"). The other day I became curious about the <code>sleep()</code> function, so tried to use it like this:</p>
<pre><code>#include <stdio.h>
#include <unistd.h>
int ma... | [
{
"answer_id": 338290,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 3,
"selected": false,
"text": "<p>Your problem is that printf (and anything else that uses the stdio library to write to stdout (standard output)) is ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm just learning C with Kernighan and Ritchie's book; I'm in the basics of the fourth chapter ("Functions and Program Structure"). The other day I became curious about the `sleep()` function, so tried to use it like this:
```
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf(" I like cows.");
sleep(... | `printf()` writes to `stdout` (the default output stream) which is usually line buffered. The buffer isn't flushed by the time `sleep` is called so nothing is displayed, when the program exits all streams are automatically flushed which is why it prints right before exiting. Printing a newline will usually cause the st... |
338,274 | <p>Ok, I have the following structure. Basically a plugin architecture</p>
<pre><code>// assembly 1 - Base Class which contains the contract
public class BaseEntity {
public string MyName() {
// figure out the name of the deriving class
// perhaps via reflection
}
}
// assembly 2 - contains plugins based... | [
{
"answer_id": 338298,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": -1,
"selected": false,
"text": "<p>Try this pattern</p>\n\n<pre><code>class BaseEntity {\n private readonly m_name as string;\n public Name { get { re... | 2008/12/03 | [
"https://Stackoverflow.com/questions/338274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | Ok, I have the following structure. Basically a plugin architecture
```
// assembly 1 - Base Class which contains the contract
public class BaseEntity {
public string MyName() {
// figure out the name of the deriving class
// perhaps via reflection
}
}
// assembly 2 - contains plugins based on the Base Cl... | I think you can do it through GetType:
```
public class BaseEntity {
public string MyName() {
return this.GetType().Name
}
}
``` |