question_id int64 4 6.31M | answer_id int64 7 6.31M | title stringlengths 9 150 | question_body stringlengths 0 28.8k | answer_body stringlengths 60 27.2k | question_text stringlengths 40 28.9k | combined_text stringlengths 124 39.6k | tags listlengths 1 6 | question_score int64 0 26.3k | answer_score int64 0 28.8k | view_count int64 15 14M | answer_count int64 0 182 | favorite_count int64 0 32 | question_creation_date stringdate 2008-07-31 21:42:52 2011-06-10 18:12:18 | answer_creation_date stringdate 2008-07-31 22:17:57 2011-06-10 18:14:17 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
35,286 | 35,386 | DOS filename escaping for use with *nix commands | I want to escape a DOS filename so I can use it with sed. I have a DOS batch file something like this: set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile (Note: %~f1 - expands %1 to a Fully qualified path name - C:\utils\MyFile.txt ) I found that the backslashes in %FILENAME% are just escaping the next letter. How can I double them up so that they are escaped? (I have cygwin installed so feel free to use any other *nix commands) Solution Combining Jeremy and Alexandru Nedelcu's suggestions, and using | for the delimiter in the sed command I have set FILENAME=%~f1 cygpath "s|Some Pattern|%FILENAME%|" >sedcmd.tmp sed -f sedcmd.tmp inputfile del /q sedcmd.tmp | This will work. It's messy because in BAT files you can't use set var=`cmd` like you can in unix. The fact that echo doesn't understand quotes is also messy, and could lead to trouble if Some Pattern contains shell meta characters. set FILENAME=%~f1 echo s/Some Pattern/%FILENAME%/ | sed -e "s/\\/\\\\/g" >sedcmd.tmp sed -f sedcmd.tmp inputfile del /q sedcmd.tmp [Edited]: I am suprised that it didn't work for you. I just tested it, and it worked on my machine. I am using sed from http://sourceforge.net/projects/unxutils and using cmd.exe to run those commands in a bat file. | DOS filename escaping for use with *nix commands I want to escape a DOS filename so I can use it with sed. I have a DOS batch file something like this: set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile (Note: %~f1 - expands %1 to a Fully qualified path name - C:\utils\MyFile.txt ) I found that the backslashes in %FILENAME% are just escaping the next letter. How can I double them up so that they are escaped? (I have cygwin installed so feel free to use any other *nix commands) Solution Combining Jeremy and Alexandru Nedelcu's suggestions, and using | for the delimiter in the sed command I have set FILENAME=%~f1 cygpath "s|Some Pattern|%FILENAME%|" >sedcmd.tmp sed -f sedcmd.tmp inputfile del /q sedcmd.tmp | TITLE:
DOS filename escaping for use with *nix commands
QUESTION:
I want to escape a DOS filename so I can use it with sed. I have a DOS batch file something like this: set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile (Note: %~f1 - expands %1 to a Fully qualified path name - C:\utils\MyFile.txt ) I found that the backslashes in %FILENAME% are just escaping the next letter. How can I double them up so that they are escaped? (I have cygwin installed so feel free to use any other *nix commands) Solution Combining Jeremy and Alexandru Nedelcu's suggestions, and using | for the delimiter in the sed command I have set FILENAME=%~f1 cygpath "s|Some Pattern|%FILENAME%|" >sedcmd.tmp sed -f sedcmd.tmp inputfile del /q sedcmd.tmp
ANSWER:
This will work. It's messy because in BAT files you can't use set var=`cmd` like you can in unix. The fact that echo doesn't understand quotes is also messy, and could lead to trouble if Some Pattern contains shell meta characters. set FILENAME=%~f1 echo s/Some Pattern/%FILENAME%/ | sed -e "s/\\/\\\\/g" >sedcmd.tmp sed -f sedcmd.tmp inputfile del /q sedcmd.tmp [Edited]: I am suprised that it didn't work for you. I just tested it, and it worked on my machine. I am using sed from http://sourceforge.net/projects/unxutils and using cmd.exe to run those commands in a bat file. | [
"scripting",
"shell",
"dos"
] | 3 | 2 | 1,091 | 3 | 0 | 2008-08-29T20:56:02.807000 | 2008-08-29T21:58:36.340000 |
35,301 | 35,314 | What is the difference between the | and || or operators? | I have always used || (two pipes) in OR expressions, both in C# and PHP. Occasionally I see a single pipe used: |. What is the difference between those two usages? Are there any caveats when using one over the other or are they interchangeable? | Just like the & and && operator, the double Operator is a "short-circuit" operator. For example: if(condition1 || condition2 || condition3) If condition1 is true, condition 2 and 3 will NOT be checked. if(condition1 | condition2 | condition3) This will check conditions 2 and 3, even if 1 is already true. As your conditions can be quite expensive functions, you can get a good performance boost by using them. There is one big caveat, NullReferences or similar problems. For example: if(class!= null && class.someVar < 20) If class is null, the if-statement will stop after class!= null is false. If you only use &, it will try to check class.someVar and you get a nice NullReferenceException. With the Or-Operator that may not be that much of a trap as it's unlikely that you trigger something bad, but it's something to keep in mind. No one ever uses the single & or | operators though, unless you have a design where each condition is a function that HAS to be executed. Sounds like a design smell, but sometimes (rarely) it's a clean way to do stuff. The & operator does "run these 3 functions, and if one of them returns false, execute the else block", while the | does "only run the else block if none return false" - can be useful, but as said, often it's a design smell. There is a Second use of the | and & operator though: Bitwise Operations. | What is the difference between the | and || or operators? I have always used || (two pipes) in OR expressions, both in C# and PHP. Occasionally I see a single pipe used: |. What is the difference between those two usages? Are there any caveats when using one over the other or are they interchangeable? | TITLE:
What is the difference between the | and || or operators?
QUESTION:
I have always used || (two pipes) in OR expressions, both in C# and PHP. Occasionally I see a single pipe used: |. What is the difference between those two usages? Are there any caveats when using one over the other or are they interchangeable?
ANSWER:
Just like the & and && operator, the double Operator is a "short-circuit" operator. For example: if(condition1 || condition2 || condition3) If condition1 is true, condition 2 and 3 will NOT be checked. if(condition1 | condition2 | condition3) This will check conditions 2 and 3, even if 1 is already true. As your conditions can be quite expensive functions, you can get a good performance boost by using them. There is one big caveat, NullReferences or similar problems. For example: if(class!= null && class.someVar < 20) If class is null, the if-statement will stop after class!= null is false. If you only use &, it will try to check class.someVar and you get a nice NullReferenceException. With the Or-Operator that may not be that much of a trap as it's unlikely that you trigger something bad, but it's something to keep in mind. No one ever uses the single & or | operators though, unless you have a design where each condition is a function that HAS to be executed. Sounds like a design smell, but sometimes (rarely) it's a clean way to do stuff. The & operator does "run these 3 functions, and if one of them returns false, execute the else block", while the | does "only run the else block if none return false" - can be useful, but as said, often it's a design smell. There is a Second use of the | and & operator though: Bitwise Operations. | [
"c#",
"php",
"operators"
] | 380 | 581 | 216,238 | 11 | 0 | 2008-08-29T21:11:17.543000 | 2008-08-29T21:17:18.340000 |
35,304 | 35,791 | FlexUnit component testing patterns: use addAsync or manually initialize? | We've been using Flex for about 6 months here at work, and I found that my first batches of FlexUnit tests involving custom components would tend to follow this sort of pattern: import mx.core.Application; import mx.events.FlexEvent; import flexunit.framework.TestCase;
public class CustomComponentTest extends TestCase { private var component:CustomComponent;
public function testSomeAspect(): void { component = new CustomComponent(); // set some properties...
component.addEventListener(FlexEvent.CREATION_COMPLETE, addAsync(verifySomeAspect, 5000));
component.height = 0; component.width = 0; Application.application.addChild(component); }
public function verifySomeAspect(event:FlexEvent): void { // Assert some things about component... }
override public function tearDown(): void { try { if (component) { Application.application.removeChild(component); component = null; } } catch (e:Error) { // ok to ignore } } Basically, you need to make sure the component has been fully initialized before you can reliably verify anything about it, and in Flex this happens asynchronously after it has been added to the display list. So you need to setup a callback (using FlexUnit's addAsync function) to be notified when that's happened. Lately i've been just manually calling the methods that the runtime would call for you in the necessary places, so now my tests tend to look more like this: import flexunit.framework.TestCase;
public class CustomComponentTest extends TestCase {
public function testSomeAspect(): void { var component:CustomComponent = new CustomComponent(); component.initialize(); // set some properties... component.validateProperties();
// Assert some things about component... } This is much easier to follow, but it kinda feels like I'm cheating a little either way. The first case is slamming it into the current Application (which would be the unit test runner shell app), and the latter isn't a "real" environment. I was wondering how other people would handle this sort of situation? | I see nothing wrong with using the async version. I can agree that the second version is shorter, but I'm not sure that I think it's easier to follow. The test does a lot of things that you wouldn't normally do, whereas the first example is more true to how you would use the component outside the test environment. Also, in the second form you have to make sure that you do exactly what the framework would do, miss one step and your test isn't relevant, and each test must repeat this code. Seems to me it's better to test it in a situation that is as close to the real thing as possible. You could have a look at dpUint 's sequences, they made component testing a little more declarative: public function testLogin():void { var passThroughData:Object = new Object();
passThroughData.username = "myuser1"; passThroughData.password = "somepsswd";
var sequence:SequenceRunner = new SequenceRunner(this);
sequence.addStep(new SequenceSetter(form.usernameTI, {text:passThroughData.username})); sequence.addStep(new SequenceWaiter(form.usernameTI, FlexEvent.VALUE_COMMIT, 100));
sequence.addStep(new SequenceSetter(form.passwordTI, {text:passThroughData.password})); sequence.addStep(new SequenceWaiter(form.passwordTI, FlexEvent.VALUE_COMMIT, 100));
sequence.addStep(new SequenceEventDispatcher(form.loginBtn, new MouseEvent("click", true, false))); sequence.addStep(new SequenceWaiter(form, "loginRequested", 100));
sequence.addAssertHandler(handleLoginEvent, passThroughData);
sequence.run(); } (example from the dpUint wiki, see here for more info ). | FlexUnit component testing patterns: use addAsync or manually initialize? We've been using Flex for about 6 months here at work, and I found that my first batches of FlexUnit tests involving custom components would tend to follow this sort of pattern: import mx.core.Application; import mx.events.FlexEvent; import flexunit.framework.TestCase;
public class CustomComponentTest extends TestCase { private var component:CustomComponent;
public function testSomeAspect(): void { component = new CustomComponent(); // set some properties...
component.addEventListener(FlexEvent.CREATION_COMPLETE, addAsync(verifySomeAspect, 5000));
component.height = 0; component.width = 0; Application.application.addChild(component); }
public function verifySomeAspect(event:FlexEvent): void { // Assert some things about component... }
override public function tearDown(): void { try { if (component) { Application.application.removeChild(component); component = null; } } catch (e:Error) { // ok to ignore } } Basically, you need to make sure the component has been fully initialized before you can reliably verify anything about it, and in Flex this happens asynchronously after it has been added to the display list. So you need to setup a callback (using FlexUnit's addAsync function) to be notified when that's happened. Lately i've been just manually calling the methods that the runtime would call for you in the necessary places, so now my tests tend to look more like this: import flexunit.framework.TestCase;
public class CustomComponentTest extends TestCase {
public function testSomeAspect(): void { var component:CustomComponent = new CustomComponent(); component.initialize(); // set some properties... component.validateProperties();
// Assert some things about component... } This is much easier to follow, but it kinda feels like I'm cheating a little either way. The first case is slamming it into the current Application (which would be the unit test runner shell app), and the latter isn't a "real" environment. I was wondering how other people would handle this sort of situation? | TITLE:
FlexUnit component testing patterns: use addAsync or manually initialize?
QUESTION:
We've been using Flex for about 6 months here at work, and I found that my first batches of FlexUnit tests involving custom components would tend to follow this sort of pattern: import mx.core.Application; import mx.events.FlexEvent; import flexunit.framework.TestCase;
public class CustomComponentTest extends TestCase { private var component:CustomComponent;
public function testSomeAspect(): void { component = new CustomComponent(); // set some properties...
component.addEventListener(FlexEvent.CREATION_COMPLETE, addAsync(verifySomeAspect, 5000));
component.height = 0; component.width = 0; Application.application.addChild(component); }
public function verifySomeAspect(event:FlexEvent): void { // Assert some things about component... }
override public function tearDown(): void { try { if (component) { Application.application.removeChild(component); component = null; } } catch (e:Error) { // ok to ignore } } Basically, you need to make sure the component has been fully initialized before you can reliably verify anything about it, and in Flex this happens asynchronously after it has been added to the display list. So you need to setup a callback (using FlexUnit's addAsync function) to be notified when that's happened. Lately i've been just manually calling the methods that the runtime would call for you in the necessary places, so now my tests tend to look more like this: import flexunit.framework.TestCase;
public class CustomComponentTest extends TestCase {
public function testSomeAspect(): void { var component:CustomComponent = new CustomComponent(); component.initialize(); // set some properties... component.validateProperties();
// Assert some things about component... } This is much easier to follow, but it kinda feels like I'm cheating a little either way. The first case is slamming it into the current Application (which would be the unit test runner shell app), and the latter isn't a "real" environment. I was wondering how other people would handle this sort of situation?
ANSWER:
I see nothing wrong with using the async version. I can agree that the second version is shorter, but I'm not sure that I think it's easier to follow. The test does a lot of things that you wouldn't normally do, whereas the first example is more true to how you would use the component outside the test environment. Also, in the second form you have to make sure that you do exactly what the framework would do, miss one step and your test isn't relevant, and each test must repeat this code. Seems to me it's better to test it in a situation that is as close to the real thing as possible. You could have a look at dpUint 's sequences, they made component testing a little more declarative: public function testLogin():void { var passThroughData:Object = new Object();
passThroughData.username = "myuser1"; passThroughData.password = "somepsswd";
var sequence:SequenceRunner = new SequenceRunner(this);
sequence.addStep(new SequenceSetter(form.usernameTI, {text:passThroughData.username})); sequence.addStep(new SequenceWaiter(form.usernameTI, FlexEvent.VALUE_COMMIT, 100));
sequence.addStep(new SequenceSetter(form.passwordTI, {text:passThroughData.password})); sequence.addStep(new SequenceWaiter(form.passwordTI, FlexEvent.VALUE_COMMIT, 100));
sequence.addStep(new SequenceEventDispatcher(form.loginBtn, new MouseEvent("click", true, false))); sequence.addStep(new SequenceWaiter(form, "loginRequested", 100));
sequence.addAssertHandler(handleLoginEvent, passThroughData);
sequence.run(); } (example from the dpUint wiki, see here for more info ). | [
"apache-flex",
"unit-testing"
] | 1 | 1 | 1,580 | 1 | 0 | 2008-08-29T21:13:57.290000 | 2008-08-30T08:47:12.397000 |
35,315 | 83,262 | How do you combine multiple result sets in SSRS? | What's the best way to combine results sets from disparate data sources in SSRS? In my particular example, I need to write a report that pulls data from SQL Server and combines it with another set of data that comes from a DB2 database. In the end, I need to join these separate data sets together so I have one combined dataset with data from both sources combined on to the same rows. (Like an inner join if both tables were coming from the same SQL DB). I know that you can't do this "out of the box" in SSRS 2005. I'm not excited about having to pull the data into a temporary table on my SQL box because users need to be able to run this report on demand and it seems like having to use SSIS to get the data into the table on demand will be slow and hard to manage with multiple users trying to get at the report simultaneously. Are there any other, more elegant solutions out there? I know that the linked server solution mentioned below would technically work, however, for some reason our DBAs will simply not allow us to use linked servers. I know that you can add two different data sets to a report, however, I need to be able to join them together. Anybody have any ideas on how to best accomplish this? | We had to do something similar (i.e. inner join 2 data sources from different servers). I believe the best way is to write your own custom Data Extension. It's not very difficult and it would give you the ability to do this and more. | How do you combine multiple result sets in SSRS? What's the best way to combine results sets from disparate data sources in SSRS? In my particular example, I need to write a report that pulls data from SQL Server and combines it with another set of data that comes from a DB2 database. In the end, I need to join these separate data sets together so I have one combined dataset with data from both sources combined on to the same rows. (Like an inner join if both tables were coming from the same SQL DB). I know that you can't do this "out of the box" in SSRS 2005. I'm not excited about having to pull the data into a temporary table on my SQL box because users need to be able to run this report on demand and it seems like having to use SSIS to get the data into the table on demand will be slow and hard to manage with multiple users trying to get at the report simultaneously. Are there any other, more elegant solutions out there? I know that the linked server solution mentioned below would technically work, however, for some reason our DBAs will simply not allow us to use linked servers. I know that you can add two different data sets to a report, however, I need to be able to join them together. Anybody have any ideas on how to best accomplish this? | TITLE:
How do you combine multiple result sets in SSRS?
QUESTION:
What's the best way to combine results sets from disparate data sources in SSRS? In my particular example, I need to write a report that pulls data from SQL Server and combines it with another set of data that comes from a DB2 database. In the end, I need to join these separate data sets together so I have one combined dataset with data from both sources combined on to the same rows. (Like an inner join if both tables were coming from the same SQL DB). I know that you can't do this "out of the box" in SSRS 2005. I'm not excited about having to pull the data into a temporary table on my SQL box because users need to be able to run this report on demand and it seems like having to use SSIS to get the data into the table on demand will be slow and hard to manage with multiple users trying to get at the report simultaneously. Are there any other, more elegant solutions out there? I know that the linked server solution mentioned below would technically work, however, for some reason our DBAs will simply not allow us to use linked servers. I know that you can add two different data sets to a report, however, I need to be able to join them together. Anybody have any ideas on how to best accomplish this?
ANSWER:
We had to do something similar (i.e. inner join 2 data sources from different servers). I believe the best way is to write your own custom Data Extension. It's not very difficult and it would give you the ability to do this and more. | [
"reporting-services"
] | 9 | 6 | 27,679 | 5 | 0 | 2008-08-29T21:17:26.033000 | 2008-09-17T13:34:51.020000 |
35,317 | 35,387 | Why does Vista complain about a dead process when I use Cygwin X11 ssh and how do I get it to shut up? | When I log into a remote machine using ssh X11 forwarding, Vista pops up a box complaining about a process that died unexpectedly. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it? Specifically, the message reads: sh.exe has stopped working So it's not ssh itself that died, but some sub-process. The problem details textbox reads: Problem signature: Problem Event Name: APPCRASH Application Name: sh.exe Application Version: 0.0.0.0 Application Timestamp: 48a031a1 Fault Module Name: comctl32.dll_unloaded Fault Module Version: 0.0.0.0 Fault Module Timestamp: 4549bcb0 Exception Code: c0000005 Exception Offset: 73dc5b17 OS Version: 6.0.6000.2.0.0.768.3 Locale ID: 1033 Additional Information 1: fc4d Additional Information 2: d203a7335117760e7b4d2cf9dc2925f9 Additional Information 3: 1bc1 Additional Information 4: 7bc0b00964c4a1bd48f87b2415df3372
Read our privacy statement: http://go.microsoft.com/fwlink/?linkid=50163&clcid=0x0409 I notice the problem occurs when I use the -Y option to enable X11 forwarding in an X terminal under Vista. The dialog box that pops up doesn't automatically gain focus, so pressing Enter serves no purpose. I have to wait for the box to appear, grab it with the mouse, and dismiss it. Even forcing the error to receive focus would be a step in the right direction. Per DrPizza I have sent an email to the Cygwin mailing list. The trimmed down subject line represents my repeated attempts to bypass an over-aggressive spam filter and highlights the need for something like StackOverflow. | Well, I don't know what the original problem was, but when I update Cygwin recently the error message stopped popping up. My guess it that rebasing was necessary. | Why does Vista complain about a dead process when I use Cygwin X11 ssh and how do I get it to shut up? When I log into a remote machine using ssh X11 forwarding, Vista pops up a box complaining about a process that died unexpectedly. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it? Specifically, the message reads: sh.exe has stopped working So it's not ssh itself that died, but some sub-process. The problem details textbox reads: Problem signature: Problem Event Name: APPCRASH Application Name: sh.exe Application Version: 0.0.0.0 Application Timestamp: 48a031a1 Fault Module Name: comctl32.dll_unloaded Fault Module Version: 0.0.0.0 Fault Module Timestamp: 4549bcb0 Exception Code: c0000005 Exception Offset: 73dc5b17 OS Version: 6.0.6000.2.0.0.768.3 Locale ID: 1033 Additional Information 1: fc4d Additional Information 2: d203a7335117760e7b4d2cf9dc2925f9 Additional Information 3: 1bc1 Additional Information 4: 7bc0b00964c4a1bd48f87b2415df3372
Read our privacy statement: http://go.microsoft.com/fwlink/?linkid=50163&clcid=0x0409 I notice the problem occurs when I use the -Y option to enable X11 forwarding in an X terminal under Vista. The dialog box that pops up doesn't automatically gain focus, so pressing Enter serves no purpose. I have to wait for the box to appear, grab it with the mouse, and dismiss it. Even forcing the error to receive focus would be a step in the right direction. Per DrPizza I have sent an email to the Cygwin mailing list. The trimmed down subject line represents my repeated attempts to bypass an over-aggressive spam filter and highlights the need for something like StackOverflow. | TITLE:
Why does Vista complain about a dead process when I use Cygwin X11 ssh and how do I get it to shut up?
QUESTION:
When I log into a remote machine using ssh X11 forwarding, Vista pops up a box complaining about a process that died unexpectedly. Once I dismiss the box, everything is fine. So I really don't care if some process died. How do I get Vista to shut up about it? Specifically, the message reads: sh.exe has stopped working So it's not ssh itself that died, but some sub-process. The problem details textbox reads: Problem signature: Problem Event Name: APPCRASH Application Name: sh.exe Application Version: 0.0.0.0 Application Timestamp: 48a031a1 Fault Module Name: comctl32.dll_unloaded Fault Module Version: 0.0.0.0 Fault Module Timestamp: 4549bcb0 Exception Code: c0000005 Exception Offset: 73dc5b17 OS Version: 6.0.6000.2.0.0.768.3 Locale ID: 1033 Additional Information 1: fc4d Additional Information 2: d203a7335117760e7b4d2cf9dc2925f9 Additional Information 3: 1bc1 Additional Information 4: 7bc0b00964c4a1bd48f87b2415df3372
Read our privacy statement: http://go.microsoft.com/fwlink/?linkid=50163&clcid=0x0409 I notice the problem occurs when I use the -Y option to enable X11 forwarding in an X terminal under Vista. The dialog box that pops up doesn't automatically gain focus, so pressing Enter serves no purpose. I have to wait for the box to appear, grab it with the mouse, and dismiss it. Even forcing the error to receive focus would be a step in the right direction. Per DrPizza I have sent an email to the Cygwin mailing list. The trimmed down subject line represents my repeated attempts to bypass an over-aggressive spam filter and highlights the need for something like StackOverflow.
ANSWER:
Well, I don't know what the original problem was, but when I update Cygwin recently the error message stopped popping up. My guess it that rebasing was necessary. | [
"windows-vista",
"ssh",
"cygwin",
"x11",
"openssh"
] | 0 | 0 | 1,158 | 5 | 0 | 2008-08-29T21:18:41.443000 | 2008-08-29T21:59:20.270000 |
35,320 | 35,557 | How do you get the last record generated in a recursive CTE? | In the code below I am using a recursive CTE(Common Table Expression) in SQL Server 2005 to try and find the top level parent of a basic hierarchical structure. The rule of this hierarchy is that every CustID has a ParentID and if the CustID has no parent then the ParentID = CustID and it is the highest level. DECLARE @LookupID int
--Our test value SET @LookupID = 1
WITH cteLevelOne (ParentID, CustID) AS ( SELECT a.ParentID, a.CustID FROM tblCustomer AS a WHERE a.CustID = @LookupID UNION ALL SELECT a.ParentID, a.CustID FROM tblCustomer AS a INNER JOIN cteLevelOne AS c ON a.CustID = c.ParentID WHERE c.CustID <> a.CustomerID ) So if tblCustomer looks like this: ParentID CustID 5 5 1 8 5 4 4 1 The result I get from the code above is: ParentID CustID 4 1 5 4 5 5 What I want is just the last row of that result: ParentID CustID 5 5 How do I just return the last record generated in the CTE (which would be highest level CustID)? Also note that there are multiple unrelated CustID hierarchies in this table so I can't just do a SELECT * FROM tblCustomer WHERE ParentID = CustID. I can't order by ParentID or CustID because the ID number is not related to where it is in the hierarchy. | If you just want want the highest recursion depth couldn't you do something like this?Then, when you actually query the CTE just look for the row with max(Depth)? Like so: DECLARE @LookupID int
--Our test value SET @LookupID = 1;
WITH cteLevelOne (ParentID, CustID, Depth) AS ( SELECT a.ParentID, a.CustID, 1 FROM tblCustomer AS a WHERE a.CustID = @LookupID UNION ALL SELECT a.ParentID, a.CustID, c.Depth + 1 FROM tblCustomer AS a INNER JOIN cteLevelOne AS c ON a.CustID = c.ParentID WHERE c.CustID <> a.CustID ) select * from CTELevelone where Depth = (select max(Depth) from CTELevelone) or, adapting what trevor suggests, this could be used with the same CTE: select top 1 * from CTELevelone order by Depth desc I don't think CustomerID was necessarily what you wanted to order by in the case you described, but I wasn't perfectly clear on the question either. | How do you get the last record generated in a recursive CTE? In the code below I am using a recursive CTE(Common Table Expression) in SQL Server 2005 to try and find the top level parent of a basic hierarchical structure. The rule of this hierarchy is that every CustID has a ParentID and if the CustID has no parent then the ParentID = CustID and it is the highest level. DECLARE @LookupID int
--Our test value SET @LookupID = 1
WITH cteLevelOne (ParentID, CustID) AS ( SELECT a.ParentID, a.CustID FROM tblCustomer AS a WHERE a.CustID = @LookupID UNION ALL SELECT a.ParentID, a.CustID FROM tblCustomer AS a INNER JOIN cteLevelOne AS c ON a.CustID = c.ParentID WHERE c.CustID <> a.CustomerID ) So if tblCustomer looks like this: ParentID CustID 5 5 1 8 5 4 4 1 The result I get from the code above is: ParentID CustID 4 1 5 4 5 5 What I want is just the last row of that result: ParentID CustID 5 5 How do I just return the last record generated in the CTE (which would be highest level CustID)? Also note that there are multiple unrelated CustID hierarchies in this table so I can't just do a SELECT * FROM tblCustomer WHERE ParentID = CustID. I can't order by ParentID or CustID because the ID number is not related to where it is in the hierarchy. | TITLE:
How do you get the last record generated in a recursive CTE?
QUESTION:
In the code below I am using a recursive CTE(Common Table Expression) in SQL Server 2005 to try and find the top level parent of a basic hierarchical structure. The rule of this hierarchy is that every CustID has a ParentID and if the CustID has no parent then the ParentID = CustID and it is the highest level. DECLARE @LookupID int
--Our test value SET @LookupID = 1
WITH cteLevelOne (ParentID, CustID) AS ( SELECT a.ParentID, a.CustID FROM tblCustomer AS a WHERE a.CustID = @LookupID UNION ALL SELECT a.ParentID, a.CustID FROM tblCustomer AS a INNER JOIN cteLevelOne AS c ON a.CustID = c.ParentID WHERE c.CustID <> a.CustomerID ) So if tblCustomer looks like this: ParentID CustID 5 5 1 8 5 4 4 1 The result I get from the code above is: ParentID CustID 4 1 5 4 5 5 What I want is just the last row of that result: ParentID CustID 5 5 How do I just return the last record generated in the CTE (which would be highest level CustID)? Also note that there are multiple unrelated CustID hierarchies in this table so I can't just do a SELECT * FROM tblCustomer WHERE ParentID = CustID. I can't order by ParentID or CustID because the ID number is not related to where it is in the hierarchy.
ANSWER:
If you just want want the highest recursion depth couldn't you do something like this?Then, when you actually query the CTE just look for the row with max(Depth)? Like so: DECLARE @LookupID int
--Our test value SET @LookupID = 1;
WITH cteLevelOne (ParentID, CustID, Depth) AS ( SELECT a.ParentID, a.CustID, 1 FROM tblCustomer AS a WHERE a.CustID = @LookupID UNION ALL SELECT a.ParentID, a.CustID, c.Depth + 1 FROM tblCustomer AS a INNER JOIN cteLevelOne AS c ON a.CustID = c.ParentID WHERE c.CustID <> a.CustID ) select * from CTELevelone where Depth = (select max(Depth) from CTELevelone) or, adapting what trevor suggests, this could be used with the same CTE: select top 1 * from CTELevelone order by Depth desc I don't think CustomerID was necessarily what you wanted to order by in the case you described, but I wasn't perfectly clear on the question either. | [
"sql",
"sql-server",
"recursion",
"common-table-expression"
] | 5 | 3 | 7,828 | 3 | 0 | 2008-08-29T21:19:24.093000 | 2008-08-30T01:42:45.613000 |
35,322 | 35,516 | Bypass Forms Authentication auto redirect to login, How to? | I'm writing an app using asp.net-mvc deploying to iis6. I'm using forms authentication. Usually when a user tries to access a resource without proper authorization I want them to be redirected to a login page. FormsAuth does this for me easy enough. Problem: Now I have an action being accessed by a console app. Whats the quickest way to have this action respond w/ status 401 instead of redirecting the request to the login page? I want the console app to be able to react to this 401 StatusCode instead of it being transparent. I'd also like to keep the default, redirect unauthorized requests to login page behavior. Note: As a test I added this to my global.asax and it didn't bypass forms auth: protected void Application_AuthenticateRequest(object sender, EventArgs e) { HttpContext.Current.SkipAuthorization = true; } @Dale and Andy I'm using the AuthorizeAttributeFilter provided in MVC preview 4. This is returning an HttpUnauthorizedResult. This result is correctly setting the statusCode to 401. The problem, as i understand it, is that asp.net is intercepting the response (since its taged as a 401) and redirecting to the login page instead of just letting it go through. I want to bypass this interception for certain urls. | Ok, I worked around this. I made a custom ActionResult (HttpForbiddenResult) and custom ActionFilter (NoFallBackAuthorize). To avoid redirection, HttpForbiddenResult marks responses with status code 403. FormsAuthentication doesn't catch responses with this code so the login redirection is effectively skipped. The NoFallBackAuthorize filter checks to see if the user is authorized much like the, included, Authorize filter. It differs in that it returns HttpForbiddenResult when access is denied. The HttpForbiddenResult is pretty trivial: public class HttpForbiddenResult: ActionResult { public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } context.HttpContext.Response.StatusCode = 0x193; // 403 } } It doesn't appear to be possible to skip the login page redirection in the FormsAuthenticationModule. | Bypass Forms Authentication auto redirect to login, How to? I'm writing an app using asp.net-mvc deploying to iis6. I'm using forms authentication. Usually when a user tries to access a resource without proper authorization I want them to be redirected to a login page. FormsAuth does this for me easy enough. Problem: Now I have an action being accessed by a console app. Whats the quickest way to have this action respond w/ status 401 instead of redirecting the request to the login page? I want the console app to be able to react to this 401 StatusCode instead of it being transparent. I'd also like to keep the default, redirect unauthorized requests to login page behavior. Note: As a test I added this to my global.asax and it didn't bypass forms auth: protected void Application_AuthenticateRequest(object sender, EventArgs e) { HttpContext.Current.SkipAuthorization = true; } @Dale and Andy I'm using the AuthorizeAttributeFilter provided in MVC preview 4. This is returning an HttpUnauthorizedResult. This result is correctly setting the statusCode to 401. The problem, as i understand it, is that asp.net is intercepting the response (since its taged as a 401) and redirecting to the login page instead of just letting it go through. I want to bypass this interception for certain urls. | TITLE:
Bypass Forms Authentication auto redirect to login, How to?
QUESTION:
I'm writing an app using asp.net-mvc deploying to iis6. I'm using forms authentication. Usually when a user tries to access a resource without proper authorization I want them to be redirected to a login page. FormsAuth does this for me easy enough. Problem: Now I have an action being accessed by a console app. Whats the quickest way to have this action respond w/ status 401 instead of redirecting the request to the login page? I want the console app to be able to react to this 401 StatusCode instead of it being transparent. I'd also like to keep the default, redirect unauthorized requests to login page behavior. Note: As a test I added this to my global.asax and it didn't bypass forms auth: protected void Application_AuthenticateRequest(object sender, EventArgs e) { HttpContext.Current.SkipAuthorization = true; } @Dale and Andy I'm using the AuthorizeAttributeFilter provided in MVC preview 4. This is returning an HttpUnauthorizedResult. This result is correctly setting the statusCode to 401. The problem, as i understand it, is that asp.net is intercepting the response (since its taged as a 401) and redirecting to the login page instead of just letting it go through. I want to bypass this interception for certain urls.
ANSWER:
Ok, I worked around this. I made a custom ActionResult (HttpForbiddenResult) and custom ActionFilter (NoFallBackAuthorize). To avoid redirection, HttpForbiddenResult marks responses with status code 403. FormsAuthentication doesn't catch responses with this code so the login redirection is effectively skipped. The NoFallBackAuthorize filter checks to see if the user is authorized much like the, included, Authorize filter. It differs in that it returns HttpForbiddenResult when access is denied. The HttpForbiddenResult is pretty trivial: public class HttpForbiddenResult: ActionResult { public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } context.HttpContext.Response.StatusCode = 0x193; // 403 } } It doesn't appear to be possible to skip the login page redirection in the FormsAuthenticationModule. | [
"asp.net",
"asp.net-mvc",
"forms-authentication"
] | 6 | 5 | 9,705 | 5 | 0 | 2008-08-29T21:20:38.723000 | 2008-08-30T00:36:31.093000 |
35,333 | 35,477 | Compiler Error C2143 when using a struct | I'm compiling a simple.c in visual c++ with Compile as C Code (/TC) and i get this compiler error error C2143: syntax error: missing ';' before 'type' on a line that calls for a simple struct struct foo test; same goes for using the typedef of the struct. error C2275: 'FOO': illegal use of this type as an expression | I forgot that in C you have to declare all your variables before any code. | Compiler Error C2143 when using a struct I'm compiling a simple.c in visual c++ with Compile as C Code (/TC) and i get this compiler error error C2143: syntax error: missing ';' before 'type' on a line that calls for a simple struct struct foo test; same goes for using the typedef of the struct. error C2275: 'FOO': illegal use of this type as an expression | TITLE:
Compiler Error C2143 when using a struct
QUESTION:
I'm compiling a simple.c in visual c++ with Compile as C Code (/TC) and i get this compiler error error C2143: syntax error: missing ';' before 'type' on a line that calls for a simple struct struct foo test; same goes for using the typedef of the struct. error C2275: 'FOO': illegal use of this type as an expression
ANSWER:
I forgot that in C you have to declare all your variables before any code. | [
"c",
"visual-c++"
] | 3 | 6 | 4,652 | 5 | 0 | 2008-08-29T21:24:52.130000 | 2008-08-29T23:52:27.797000 |
35,357 | 35,408 | Minimalistic Database Administration | I am a developer. An architect on good days. Somehow I find myself also being the DBA for my small company. My background is fair in the DB arts but I have never been a full fledged DBA. My question is what do I have to do to ensure a realiable and reasonably functional database environment with as little actual effort as possible? I am sure that I need to make sure that backups are being performed and that is being done. That is an easy one. What else should I be doing on a consistant basis? | Who else is involved in the database? Are you the only person making schema changes (creating new objects, releasing new stored procedures, permissioning new users)? Make sure that the number of users doing anything that could impact performance is reduced to as close to zero as possible, ideally including you. Make sure that you're testing your backups - ideally run a DEV box that is recreating the production environment periodically, 1. a DEV box is a good idea, 2. a backup is only useful if you can restore from it. Create groups for the various apps that connect to your database, so when a new user comes along you don't guess what permissions they need, just add them to the group, meanwhile permission the database objects to only the groups that need them Use indices, primary keys, foreign keys, constraints, stats and whatever other tools your database supports. Normalise. Optimise the most common code against your box - bad stored procedures/data access code will kill you. | Minimalistic Database Administration I am a developer. An architect on good days. Somehow I find myself also being the DBA for my small company. My background is fair in the DB arts but I have never been a full fledged DBA. My question is what do I have to do to ensure a realiable and reasonably functional database environment with as little actual effort as possible? I am sure that I need to make sure that backups are being performed and that is being done. That is an easy one. What else should I be doing on a consistant basis? | TITLE:
Minimalistic Database Administration
QUESTION:
I am a developer. An architect on good days. Somehow I find myself also being the DBA for my small company. My background is fair in the DB arts but I have never been a full fledged DBA. My question is what do I have to do to ensure a realiable and reasonably functional database environment with as little actual effort as possible? I am sure that I need to make sure that backups are being performed and that is being done. That is an easy one. What else should I be doing on a consistant basis?
ANSWER:
Who else is involved in the database? Are you the only person making schema changes (creating new objects, releasing new stored procedures, permissioning new users)? Make sure that the number of users doing anything that could impact performance is reduced to as close to zero as possible, ideally including you. Make sure that you're testing your backups - ideally run a DEV box that is recreating the production environment periodically, 1. a DEV box is a good idea, 2. a backup is only useful if you can restore from it. Create groups for the various apps that connect to your database, so when a new user comes along you don't guess what permissions they need, just add them to the group, meanwhile permission the database objects to only the groups that need them Use indices, primary keys, foreign keys, constraints, stats and whatever other tools your database supports. Normalise. Optimise the most common code against your box - bad stored procedures/data access code will kill you. | [
"database",
"administration",
"task"
] | 3 | 5 | 305 | 3 | 0 | 2008-08-29T21:36:27.093000 | 2008-08-29T22:19:20.017000 |
35,366 | 35,369 | What are the main performance differences between varchar and nvarchar SQL Server data types? | I'm working on a database for a small web app at my school using SQL Server 2005. I see a couple of schools of thought on the issue of varchar vs nvarchar: Use varchar unless you deal with a lot of internationalized data, then use nvarchar. Just use nvarchar for everything. I'm beginning to see the merits of view 2. I know that nvarchar does take up twice as much space, but that isn't necessarily a huge deal since this is only going to store data for a few hundred students. To me it seems like it would be easiest not to worry about it and just allow everything to use nvarchar. Or is there something I'm missing? | Always use nvarchar. You may never need the double-byte characters for most applications. However, if you need to support double-byte languages and you only have single-byte support in your database schema it's really expensive to go back and modify throughout your application. The cost of migrating one application from varchar to nvarchar will be much more than the little bit of extra disk space you'll use in most applications. | What are the main performance differences between varchar and nvarchar SQL Server data types? I'm working on a database for a small web app at my school using SQL Server 2005. I see a couple of schools of thought on the issue of varchar vs nvarchar: Use varchar unless you deal with a lot of internationalized data, then use nvarchar. Just use nvarchar for everything. I'm beginning to see the merits of view 2. I know that nvarchar does take up twice as much space, but that isn't necessarily a huge deal since this is only going to store data for a few hundred students. To me it seems like it would be easiest not to worry about it and just allow everything to use nvarchar. Or is there something I'm missing? | TITLE:
What are the main performance differences between varchar and nvarchar SQL Server data types?
QUESTION:
I'm working on a database for a small web app at my school using SQL Server 2005. I see a couple of schools of thought on the issue of varchar vs nvarchar: Use varchar unless you deal with a lot of internationalized data, then use nvarchar. Just use nvarchar for everything. I'm beginning to see the merits of view 2. I know that nvarchar does take up twice as much space, but that isn't necessarily a huge deal since this is only going to store data for a few hundred students. To me it seems like it would be easiest not to worry about it and just allow everything to use nvarchar. Or is there something I'm missing?
ANSWER:
Always use nvarchar. You may never need the double-byte characters for most applications. However, if you need to support double-byte languages and you only have single-byte support in your database schema it's really expensive to go back and modify throughout your application. The cost of migrating one application from varchar to nvarchar will be much more than the little bit of extra disk space you'll use in most applications. | [
"sql-server",
"sql-server-2005",
"storage",
"varchar",
"nvarchar"
] | 248 | 131 | 188,249 | 14 | 0 | 2008-08-29T21:41:57.267000 | 2008-08-29T21:44:41.600000 |
35,372 | 67,345 | How can I change the way my Drupal theme displays the front page | I am trying to build an website for my college's magazine. I used the "views" module to show a block of static content I created on the front page. My question is: how can I edit the theme's css so it changes the way that block of static content is displayed? For reference, here's the link to the site (in portuguese, and with almost zero content for now). | The main css file that drives your content is the styles.css file located in your currently selected theme. In your case that means that most of your site styling is driven by this file: /aroda/roda/themes/garland/style.css with basic coloring effects handled by this file: /aroda/roda/files/color/garland-d3985506/style.css You're currently using Garland, the default Drupal theme included with the core download, so for best practices you shouldn't edit the included style.css file directly. Instead, you should, as Daniel James said, create a subdirectory in /sites/all called "themes". If you're using Drupal 6, I'd follow Daniel James directions from there. If you're using Drupal 5, I'd go ahead and copy the garland directory into the themes directory and rename it for something specific to your site (aroda_v1) so you would have something like /sites/all/themes/aroda_v1 which would contain styles.css. At that point, you can edit the styles.css file directly to make any changes you see fit. Hope that helps! | How can I change the way my Drupal theme displays the front page I am trying to build an website for my college's magazine. I used the "views" module to show a block of static content I created on the front page. My question is: how can I edit the theme's css so it changes the way that block of static content is displayed? For reference, here's the link to the site (in portuguese, and with almost zero content for now). | TITLE:
How can I change the way my Drupal theme displays the front page
QUESTION:
I am trying to build an website for my college's magazine. I used the "views" module to show a block of static content I created on the front page. My question is: how can I edit the theme's css so it changes the way that block of static content is displayed? For reference, here's the link to the site (in portuguese, and with almost zero content for now).
ANSWER:
The main css file that drives your content is the styles.css file located in your currently selected theme. In your case that means that most of your site styling is driven by this file: /aroda/roda/themes/garland/style.css with basic coloring effects handled by this file: /aroda/roda/files/color/garland-d3985506/style.css You're currently using Garland, the default Drupal theme included with the core download, so for best practices you shouldn't edit the included style.css file directly. Instead, you should, as Daniel James said, create a subdirectory in /sites/all called "themes". If you're using Drupal 6, I'd follow Daniel James directions from there. If you're using Drupal 5, I'd go ahead and copy the garland directory into the themes directory and rename it for something specific to your site (aroda_v1) so you would have something like /sites/all/themes/aroda_v1 which would contain styles.css. At that point, you can edit the styles.css file directly to make any changes you see fit. Hope that helps! | [
"drupal",
"drupal-theming"
] | 5 | 3 | 9,494 | 3 | 0 | 2008-08-29T21:48:22.633000 | 2008-09-15T21:49:13.190000 |
35,373 | 35,384 | Best practices for signing .NET assemblies? | I have a solution consisting of five projects, each of which compile to separate assemblies. Right now I'm code-signing them, but I'm pretty sure I'm doing it wrong. What's the best practice here? Sign each with a different key; make sure the passwords are different Sign each with a different key; use the same password if you want Sign each with the same key Something else entirely Basically I'm not quite sure what "signing" does to them, or what the best practices are here, so a more generally discussion would be good. All I really know is that FxCop yelled at me, and it was easy to fix by clicking the "Sign this assembly" checkbox and generating a.pfx file using Visual Studio (2008). | If your only objective is to stop FxCop from yelling at you, then you have found the best practice. The best practice for signing your assemblies is something that is completely dependent on your objectives and needs. We would need more information like your intended deployment: For personal use For use on corporate network PC's as a client application Running on a web server Running in SQL Server Downloaded over the internet Sold on a CD in shrink wrap Uploaded straight into a cybernetic brain Etc. Generally you use code signing to verify that the Assemblies came from a specific trusted source and have not been modified. So each with the same key is fine. Now how that trust and identity is determined is another story. UPDATE: How this benefits your end users when you are deploying over the web is if you have obtained a software signing certificate from a certificate authority. Then when they download your assemblies they can verify they came from Domenic's Software Emporium, and they haven't been modified or corrupted along the way. You will also want to sign the installer when it is downloaded. This prevents the warning that some browsers display that it has been obtained from an unknown source. Note, you will pay for a software signing certificate. What you get is the certificate authority become the trusted 3rd party who verifies you are who you say you are. This works because of a web of trust that traces its way back to a root certificate that is installed in their operating system. There are a few certificate authorities to choose from, but you will want to make sure they are supported by the root certificates on the target operating system. | Best practices for signing .NET assemblies? I have a solution consisting of five projects, each of which compile to separate assemblies. Right now I'm code-signing them, but I'm pretty sure I'm doing it wrong. What's the best practice here? Sign each with a different key; make sure the passwords are different Sign each with a different key; use the same password if you want Sign each with the same key Something else entirely Basically I'm not quite sure what "signing" does to them, or what the best practices are here, so a more generally discussion would be good. All I really know is that FxCop yelled at me, and it was easy to fix by clicking the "Sign this assembly" checkbox and generating a.pfx file using Visual Studio (2008). | TITLE:
Best practices for signing .NET assemblies?
QUESTION:
I have a solution consisting of five projects, each of which compile to separate assemblies. Right now I'm code-signing them, but I'm pretty sure I'm doing it wrong. What's the best practice here? Sign each with a different key; make sure the passwords are different Sign each with a different key; use the same password if you want Sign each with the same key Something else entirely Basically I'm not quite sure what "signing" does to them, or what the best practices are here, so a more generally discussion would be good. All I really know is that FxCop yelled at me, and it was easy to fix by clicking the "Sign this assembly" checkbox and generating a.pfx file using Visual Studio (2008).
ANSWER:
If your only objective is to stop FxCop from yelling at you, then you have found the best practice. The best practice for signing your assemblies is something that is completely dependent on your objectives and needs. We would need more information like your intended deployment: For personal use For use on corporate network PC's as a client application Running on a web server Running in SQL Server Downloaded over the internet Sold on a CD in shrink wrap Uploaded straight into a cybernetic brain Etc. Generally you use code signing to verify that the Assemblies came from a specific trusted source and have not been modified. So each with the same key is fine. Now how that trust and identity is determined is another story. UPDATE: How this benefits your end users when you are deploying over the web is if you have obtained a software signing certificate from a certificate authority. Then when they download your assemblies they can verify they came from Domenic's Software Emporium, and they haven't been modified or corrupted along the way. You will also want to sign the installer when it is downloaded. This prevents the warning that some browsers display that it has been obtained from an unknown source. Note, you will pay for a software signing certificate. What you get is the certificate authority become the trusted 3rd party who verifies you are who you say you are. This works because of a web of trust that traces its way back to a root certificate that is installed in their operating system. There are a few certificate authorities to choose from, but you will want to make sure they are supported by the root certificates on the target operating system. | [
".net",
"assemblies",
"signing"
] | 46 | 44 | 14,527 | 5 | 0 | 2008-08-29T21:48:32.603000 | 2008-08-29T21:56:56.983000 |
35,402 | 35,421 | Encapsulate multiple properties at once using Resharper 4.0 | When using Resharper to encapsulate a class's properties, is there a way to get it to do more than one property at a time? | You might or might not already know this (R# does suffer from a lack of discoverability, unless you get the one-page key-shortcut page printed out), but ALT-INS opens a box which can at least mass-generate properties for fields. Not sure if that's any use - it's not the same as a retrospective encapsulation. | Encapsulate multiple properties at once using Resharper 4.0 When using Resharper to encapsulate a class's properties, is there a way to get it to do more than one property at a time? | TITLE:
Encapsulate multiple properties at once using Resharper 4.0
QUESTION:
When using Resharper to encapsulate a class's properties, is there a way to get it to do more than one property at a time?
ANSWER:
You might or might not already know this (R# does suffer from a lack of discoverability, unless you get the one-page key-shortcut page printed out), but ALT-INS opens a box which can at least mass-generate properties for fields. Not sure if that's any use - it's not the same as a retrospective encapsulation. | [
"visual-studio",
"resharper"
] | 5 | 9 | 1,002 | 2 | 0 | 2008-08-29T22:10:02.333000 | 2008-08-29T22:33:42.790000 |
35,420 | 35,438 | How do I oversee my MySQL replication server? | I've had a tough time setting up my replication server. Is there any program (OS X, Windows, Linux, or PHP no problem) that lets me monitor and resolve replication issues? (btw, for those following, I've been on this issue here, here, here and here ) My production database is several megs in size and growing. Every time the database replication stops and the databases inevitably begin to slide out of sync i cringe. My last resync from dump took almost 4 hours roundtrip! As always, even after sync, I run into this kind of show-stopping error: Error 'Duplicate entry '252440' for key 1' on query. I would love it if there was some way to closely monitor whats going on and perhaps let the software deal with it. I'm even all ears for service companies which may help me monitor my data better. Or an alternate way to mirror altogether. Edit: going through my previous questions i found this which helps tremendously. I'm still all ears on the monitoring solution. | To monitor the servers we use the free tools from Maatkit... simple, yet efficient. The binary replication is available in 5.1, so I guess you've got some balls. We still use 5.0 and it works OK, but of course we had our share of issues with it. We use a Master-Master replication with a MySql Proxy as a load-balancer in front, and to prevent it from having errors: we removed all unique indexes for the few cases where we really needed unique constraints we made sure we used REPLACE instead of INSERT (MySql Proxy can be used to guard for proper usage... it can even rewrite your queries) scheduled scripts doing intensive reports are always accessing the same server (not the load-balancer)... so that dangerous operations are replicated safely Yeah, I know it sounds simple and stupid, but it solved 95% of all the problems we had. | How do I oversee my MySQL replication server? I've had a tough time setting up my replication server. Is there any program (OS X, Windows, Linux, or PHP no problem) that lets me monitor and resolve replication issues? (btw, for those following, I've been on this issue here, here, here and here ) My production database is several megs in size and growing. Every time the database replication stops and the databases inevitably begin to slide out of sync i cringe. My last resync from dump took almost 4 hours roundtrip! As always, even after sync, I run into this kind of show-stopping error: Error 'Duplicate entry '252440' for key 1' on query. I would love it if there was some way to closely monitor whats going on and perhaps let the software deal with it. I'm even all ears for service companies which may help me monitor my data better. Or an alternate way to mirror altogether. Edit: going through my previous questions i found this which helps tremendously. I'm still all ears on the monitoring solution. | TITLE:
How do I oversee my MySQL replication server?
QUESTION:
I've had a tough time setting up my replication server. Is there any program (OS X, Windows, Linux, or PHP no problem) that lets me monitor and resolve replication issues? (btw, for those following, I've been on this issue here, here, here and here ) My production database is several megs in size and growing. Every time the database replication stops and the databases inevitably begin to slide out of sync i cringe. My last resync from dump took almost 4 hours roundtrip! As always, even after sync, I run into this kind of show-stopping error: Error 'Duplicate entry '252440' for key 1' on query. I would love it if there was some way to closely monitor whats going on and perhaps let the software deal with it. I'm even all ears for service companies which may help me monitor my data better. Or an alternate way to mirror altogether. Edit: going through my previous questions i found this which helps tremendously. I'm still all ears on the monitoring solution.
ANSWER:
To monitor the servers we use the free tools from Maatkit... simple, yet efficient. The binary replication is available in 5.1, so I guess you've got some balls. We still use 5.0 and it works OK, but of course we had our share of issues with it. We use a Master-Master replication with a MySql Proxy as a load-balancer in front, and to prevent it from having errors: we removed all unique indexes for the few cases where we really needed unique constraints we made sure we used REPLACE instead of INSERT (MySql Proxy can be used to guard for proper usage... it can even rewrite your queries) scheduled scripts doing intensive reports are always accessing the same server (not the load-balancer)... so that dangerous operations are replicated safely Yeah, I know it sounds simple and stupid, but it solved 95% of all the problems we had. | [
"mysql"
] | 2 | 3 | 441 | 2 | 0 | 2008-08-29T22:30:03.033000 | 2008-08-29T22:49:44.140000 |
35,429 | 35,433 | nmake, visualstudio, and .mak files | I was given a C++ project that was compiled using MS Visual Studio.net 2003 C++ compiler, and a.mak file that was used to compile it. I am able to build it from the command line using nmake project.mak, but the compiler complains that afxres.h was not found. I did a little searching around and the afxres.h is in the Visual Studio directory in an includes file. Where am I supposed to specify to nmake where to look for this header file? | There should be an icon in your Start menu under Programs that opens a cmd.exe instance with all the correct MSVS environment variables set up for command line building. | nmake, visualstudio, and .mak files I was given a C++ project that was compiled using MS Visual Studio.net 2003 C++ compiler, and a.mak file that was used to compile it. I am able to build it from the command line using nmake project.mak, but the compiler complains that afxres.h was not found. I did a little searching around and the afxres.h is in the Visual Studio directory in an includes file. Where am I supposed to specify to nmake where to look for this header file? | TITLE:
nmake, visualstudio, and .mak files
QUESTION:
I was given a C++ project that was compiled using MS Visual Studio.net 2003 C++ compiler, and a.mak file that was used to compile it. I am able to build it from the command line using nmake project.mak, but the compiler complains that afxres.h was not found. I did a little searching around and the afxres.h is in the Visual Studio directory in an includes file. Where am I supposed to specify to nmake where to look for this header file?
ANSWER:
There should be an icon in your Start menu under Programs that opens a cmd.exe instance with all the correct MSVS environment variables set up for command line building. | [
"visual-studio",
"nmake"
] | 1 | 4 | 4,153 | 2 | 0 | 2008-08-29T22:42:01.290000 | 2008-08-29T22:48:10.213000 |
35,432 | 35,441 | How can I point Visual Studio 2008 to a new path for projects? | I didn't see the option to point the workspace (or it's VS equivalent, I'm still learning the terminology for Visual Studio, but it is called a workspace in Eclipse) to My Documents/Programming instead of -- well -- wherever it is now. | What Craig said, plus if you do want to change the default it's in Tools -> Options -> Projects And Solutions. I've never changed the default and never created a solution/project in the default location, which might tell you something about how relevant it is... | How can I point Visual Studio 2008 to a new path for projects? I didn't see the option to point the workspace (or it's VS equivalent, I'm still learning the terminology for Visual Studio, but it is called a workspace in Eclipse) to My Documents/Programming instead of -- well -- wherever it is now. | TITLE:
How can I point Visual Studio 2008 to a new path for projects?
QUESTION:
I didn't see the option to point the workspace (or it's VS equivalent, I'm still learning the terminology for Visual Studio, but it is called a workspace in Eclipse) to My Documents/Programming instead of -- well -- wherever it is now.
ANSWER:
What Craig said, plus if you do want to change the default it's in Tools -> Options -> Projects And Solutions. I've never changed the default and never created a solution/project in the default location, which might tell you something about how relevant it is... | [
"visual-studio"
] | 1 | 1 | 242 | 3 | 0 | 2008-08-29T22:47:47.953000 | 2008-08-29T22:52:16.507000 |
35,479 | 47,221 | Exception in Web Service locks DLL and prevents publishing. Workaround? | I'm using a native DLL (FastImage.dll) in a C# ASP.NET Web Service that sometimes locks (can't delete it---says access denied); this requires stopping IIS to delete the DLL. The inability to delete this DLL in the bin folder of my published Web Service prevents me from publishing successfully (even though it thinks it published successfully!), which makes development and fixing the bug difficult (especially when it just happily runs old code since my changes may not be reflected on the server!). Note that the bug causing the Web Service to bomb and lock up the DLL is in my code, which is outside of said DLL, so I think this is a more general problem than just the FreeImage library (not to bring them any heat). Has anyone experienced this? Is there a way to make sure that when it says "Publish succeeded" from the VS IDE that it really means it, or to run sort of script to check that the files are really deleted before it attempts to Publish (like a pre-build step in VC++). (Right now I manually delete the files before publishing to make sure that I know the DLLs were replaced, instead of running old DLLs. It's still a problem, though if I can't delete the DLL.) How would I detect whether a file was successfully deleted from a batch file? (so I can stop and start IIS if it fails) Is it possible to stop and start IIS from a script (preferably from the Publish... action in the VS IDE) and if so, how? | Using the IISReset command line tool will only restart IIS on the local machine, not on a remote server to which you are publishing. Assuming that you are publishing to a Windows 2003 server, I'd suggest trying the slightly less drastic step of stopping and restarting the IIS AppPool in the web site or virtual folder in which the web service runs. (That way you are not taking all sites that run on the target server offline.) This too assumes that the web service runs in its own app pool. Ideally it should, so you keep it isolated. I'd recommend getting away from using the Publishing process and to look into using a Web Deployment Project. Here is a post on ScottGu's blog detailing VS 2005 Web Deployment Projects. The advantage to the Web Deployment Project approach is that it provides you with all the power and capability of MSbuild, as it is really just a convenience wrapper around MSBuild. Here's a post from the MSBuild team about pre-build and post-build capabilities Hope this helps. | Exception in Web Service locks DLL and prevents publishing. Workaround? I'm using a native DLL (FastImage.dll) in a C# ASP.NET Web Service that sometimes locks (can't delete it---says access denied); this requires stopping IIS to delete the DLL. The inability to delete this DLL in the bin folder of my published Web Service prevents me from publishing successfully (even though it thinks it published successfully!), which makes development and fixing the bug difficult (especially when it just happily runs old code since my changes may not be reflected on the server!). Note that the bug causing the Web Service to bomb and lock up the DLL is in my code, which is outside of said DLL, so I think this is a more general problem than just the FreeImage library (not to bring them any heat). Has anyone experienced this? Is there a way to make sure that when it says "Publish succeeded" from the VS IDE that it really means it, or to run sort of script to check that the files are really deleted before it attempts to Publish (like a pre-build step in VC++). (Right now I manually delete the files before publishing to make sure that I know the DLLs were replaced, instead of running old DLLs. It's still a problem, though if I can't delete the DLL.) How would I detect whether a file was successfully deleted from a batch file? (so I can stop and start IIS if it fails) Is it possible to stop and start IIS from a script (preferably from the Publish... action in the VS IDE) and if so, how? | TITLE:
Exception in Web Service locks DLL and prevents publishing. Workaround?
QUESTION:
I'm using a native DLL (FastImage.dll) in a C# ASP.NET Web Service that sometimes locks (can't delete it---says access denied); this requires stopping IIS to delete the DLL. The inability to delete this DLL in the bin folder of my published Web Service prevents me from publishing successfully (even though it thinks it published successfully!), which makes development and fixing the bug difficult (especially when it just happily runs old code since my changes may not be reflected on the server!). Note that the bug causing the Web Service to bomb and lock up the DLL is in my code, which is outside of said DLL, so I think this is a more general problem than just the FreeImage library (not to bring them any heat). Has anyone experienced this? Is there a way to make sure that when it says "Publish succeeded" from the VS IDE that it really means it, or to run sort of script to check that the files are really deleted before it attempts to Publish (like a pre-build step in VC++). (Right now I manually delete the files before publishing to make sure that I know the DLLs were replaced, instead of running old DLLs. It's still a problem, though if I can't delete the DLL.) How would I detect whether a file was successfully deleted from a batch file? (so I can stop and start IIS if it fails) Is it possible to stop and start IIS from a script (preferably from the Publish... action in the VS IDE) and if so, how?
ANSWER:
Using the IISReset command line tool will only restart IIS on the local machine, not on a remote server to which you are publishing. Assuming that you are publishing to a Windows 2003 server, I'd suggest trying the slightly less drastic step of stopping and restarting the IIS AppPool in the web site or virtual folder in which the web service runs. (That way you are not taking all sites that run on the target server offline.) This too assumes that the web service runs in its own app pool. Ideally it should, so you keep it isolated. I'd recommend getting away from using the Publishing process and to look into using a Web Deployment Project. Here is a post on ScottGu's blog detailing VS 2005 Web Deployment Projects. The advantage to the Web Deployment Project approach is that it provides you with all the power and capability of MSbuild, as it is really just a convenience wrapper around MSBuild. Here's a post from the MSBuild team about pre-build and post-build capabilities Hope this helps. | [
"c#",
"asp.net",
"visual-studio",
"web-services",
"iis"
] | 2 | 2 | 1,124 | 2 | 0 | 2008-08-29T23:55:09.350000 | 2008-09-06T03:09:26.077000 |
35,480 | 35,529 | How can I clear Class::DBI's internal cache? | I'm currently working on a large implementation of Class::DBI for an existing database structure, and am running into a problem with clearing the cache from Class::DBI. This is a mod_perl implementation, so an instance of a class can be quite old between times that it is accessed. From the man pages I found two options: Music::DBI->clear_object_index(); And: Music::Artist->purge_object_index_every(2000); Now, when I add clear_object_index() to the DESTROY method, it seems to run, but doesn't actually empty the cache. I am able to manually change the database, re-run the request, and it is still the old version. purge_object_index_every says that it clears the index every n requests. Setting this to "1" or "0", seems to clear the index... sometimes. I'd expect one of those two to work, but for some reason it doesn't do it every time. More like 1 in 5 times. Any suggestions for clearing this out? | The " common problems " page on the Class::DBI wiki has a section on this subject. The simplest solution is to disable the live object index entirely using: $Class::DBI::Weaken_Is_Available = 0; | How can I clear Class::DBI's internal cache? I'm currently working on a large implementation of Class::DBI for an existing database structure, and am running into a problem with clearing the cache from Class::DBI. This is a mod_perl implementation, so an instance of a class can be quite old between times that it is accessed. From the man pages I found two options: Music::DBI->clear_object_index(); And: Music::Artist->purge_object_index_every(2000); Now, when I add clear_object_index() to the DESTROY method, it seems to run, but doesn't actually empty the cache. I am able to manually change the database, re-run the request, and it is still the old version. purge_object_index_every says that it clears the index every n requests. Setting this to "1" or "0", seems to clear the index... sometimes. I'd expect one of those two to work, but for some reason it doesn't do it every time. More like 1 in 5 times. Any suggestions for clearing this out? | TITLE:
How can I clear Class::DBI's internal cache?
QUESTION:
I'm currently working on a large implementation of Class::DBI for an existing database structure, and am running into a problem with clearing the cache from Class::DBI. This is a mod_perl implementation, so an instance of a class can be quite old between times that it is accessed. From the man pages I found two options: Music::DBI->clear_object_index(); And: Music::Artist->purge_object_index_every(2000); Now, when I add clear_object_index() to the DESTROY method, it seems to run, but doesn't actually empty the cache. I am able to manually change the database, re-run the request, and it is still the old version. purge_object_index_every says that it clears the index every n requests. Setting this to "1" or "0", seems to clear the index... sometimes. I'd expect one of those two to work, but for some reason it doesn't do it every time. More like 1 in 5 times. Any suggestions for clearing this out?
ANSWER:
The " common problems " page on the Class::DBI wiki has a section on this subject. The simplest solution is to disable the live object index entirely using: $Class::DBI::Weaken_Is_Available = 0; | [
"perl",
"class-dbi"
] | 2 | 5 | 1,569 | 4 | 0 | 2008-08-29T23:56:27.303000 | 2008-08-30T00:54:08.477000 |
35,485 | 35,738 | Linux: What is the best way to estimate the code & static data size of program? | I want to be able to get an estimate of how much code & static data is used by my C++ program? Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime? Will objdump & readelf help? | "size" is the traditional tool. "readelf" has a lot of options. $ size /bin/sh text data bss dec hex filename 712739 37524 21832 772095 bc7ff /bin/sh | Linux: What is the best way to estimate the code & static data size of program? I want to be able to get an estimate of how much code & static data is used by my C++ program? Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime? Will objdump & readelf help? | TITLE:
Linux: What is the best way to estimate the code & static data size of program?
QUESTION:
I want to be able to get an estimate of how much code & static data is used by my C++ program? Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime? Will objdump & readelf help?
ANSWER:
"size" is the traditional tool. "readelf" has a lot of options. $ size /bin/sh text data bss dec hex filename 712739 37524 21832 772095 bc7ff /bin/sh | [
"c++",
"linux",
"unix"
] | 2 | 5 | 1,459 | 4 | 0 | 2008-08-30T00:03:39.253000 | 2008-08-30T06:24:05.780000 |
35,486 | 35,609 | Fluid rounded corners with jQuery | What is the best way to create fluid width/height rounded corners with jQuery? That plugin doesn't keep the height the same. I have a 10px high div that I want to round the corners on, when I use that script it adds about 10px onto whats there. | I use: Jquery-roundcorners-canvas it handles borders, and keeps things the same size, in fact you have to pad in a bit to keep from having letters live in the crease. Its pretty fast, unless you are on ie 6. Same pretty syntax of the other corner packs, but just prettier in general. Edited to add new link for jQuery Roundcorners Canvas | Fluid rounded corners with jQuery What is the best way to create fluid width/height rounded corners with jQuery? That plugin doesn't keep the height the same. I have a 10px high div that I want to round the corners on, when I use that script it adds about 10px onto whats there. | TITLE:
Fluid rounded corners with jQuery
QUESTION:
What is the best way to create fluid width/height rounded corners with jQuery? That plugin doesn't keep the height the same. I have a 10px high div that I want to round the corners on, when I use that script it adds about 10px onto whats there.
ANSWER:
I use: Jquery-roundcorners-canvas it handles borders, and keeps things the same size, in fact you have to pad in a bit to keep from having letters live in the crease. Its pretty fast, unless you are on ie 6. Same pretty syntax of the other corner packs, but just prettier in general. Edited to add new link for jQuery Roundcorners Canvas | [
"jquery"
] | 15 | 9 | 15,516 | 4 | 0 | 2008-08-30T00:04:38.440000 | 2008-08-30T02:35:18.110000 |
35,490 | 65,385 | Spread vs MPI vs zeromq? | In one of the answers to Broadcast like UDP with the Reliability of TCP, a user mentions the Spread messaging API. I've also run across one called ØMQ. I also have some familiarity with MPI. So, my main question is: why would I choose one over the other? More specifically, why would I choose to use Spread or ØMQ when there are mature implementations of MPI to be had? | MPI was deisgned tightly-coupled compute clusters with fast, reliable networks. Spread and ØMQ are designed for large distributed systems. If you're designing a parallel scientific application, go with MPI, but if you are designing a persistent distributed system that needs to be resilient to faults and network instability, use one of the others. MPI has very limited facilities for fault tolerance; the default error handling behavior in most implementations is a system-wide fail. Also, the semantics of MPI require that all messages sent eventually be consumed. This makes a lot of sense for simulations on a cluster, but not for a distributed application. | Spread vs MPI vs zeromq? In one of the answers to Broadcast like UDP with the Reliability of TCP, a user mentions the Spread messaging API. I've also run across one called ØMQ. I also have some familiarity with MPI. So, my main question is: why would I choose one over the other? More specifically, why would I choose to use Spread or ØMQ when there are mature implementations of MPI to be had? | TITLE:
Spread vs MPI vs zeromq?
QUESTION:
In one of the answers to Broadcast like UDP with the Reliability of TCP, a user mentions the Spread messaging API. I've also run across one called ØMQ. I also have some familiarity with MPI. So, my main question is: why would I choose one over the other? More specifically, why would I choose to use Spread or ØMQ when there are mature implementations of MPI to be had?
ANSWER:
MPI was deisgned tightly-coupled compute clusters with fast, reliable networks. Spread and ØMQ are designed for large distributed systems. If you're designing a parallel scientific application, go with MPI, but if you are designing a persistent distributed system that needs to be resilient to faults and network instability, use one of the others. MPI has very limited facilities for fault tolerance; the default error handling behavior in most implementations is a system-wide fail. Also, the semantics of MPI require that all messages sent eventually be consumed. This makes a lot of sense for simulations on a cluster, but not for a distributed application. | [
"api",
"networking",
"messaging",
"distributed",
"cluster-computing"
] | 48 | 57 | 14,429 | 3 | 0 | 2008-08-30T00:07:41.770000 | 2008-09-15T18:22:19.567000 |
35,491 | 35,694 | Mac OS X: What is the best way to estimate the code & static data size of program? | I want to be able to get an estimate of how much code & static data is used by my C++ program? Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime? Will otool help? | "size" is the traditional tool and works on all unix flavors. "otool" has a bit finer grain control and has a lot of options.. $ size python __TEXT __DATA __OBJC others dec hex 860160 159744 0 2453504 3473408 350000 | Mac OS X: What is the best way to estimate the code & static data size of program? I want to be able to get an estimate of how much code & static data is used by my C++ program? Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime? Will otool help? | TITLE:
Mac OS X: What is the best way to estimate the code & static data size of program?
QUESTION:
I want to be able to get an estimate of how much code & static data is used by my C++ program? Is there a way to find this out by looking at the executable or object files? Or perhaps something I can do at runtime? Will otool help?
ANSWER:
"size" is the traditional tool and works on all unix flavors. "otool" has a bit finer grain control and has a lot of options.. $ size python __TEXT __DATA __OBJC others dec hex 860160 159744 0 2453504 3473408 350000 | [
"macos",
"mach-o"
] | 3 | 8 | 2,474 | 2 | 0 | 2008-08-30T00:09:38.817000 | 2008-08-30T05:12:31.397000 |
35,494 | 35,596 | Is there anyway to run Ruby on Rails applications on a Windows box? | I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine? Also, this will be an internal app, so performance isn't my number once concern. | Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either.:) Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems. From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems. Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details. Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set. You might run into some gems (such as BackgroundRB ) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine. | Is there anyway to run Ruby on Rails applications on a Windows box? I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine? Also, this will be an internal app, so performance isn't my number once concern. | TITLE:
Is there anyway to run Ruby on Rails applications on a Windows box?
QUESTION:
I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine? Also, this will be an internal app, so performance isn't my number once concern.
ANSWER:
Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either.:) Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems. From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems. Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details. Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set. You might run into some gems (such as BackgroundRB ) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine. | [
"ruby-on-rails",
"windows",
"ruby"
] | 8 | 8 | 2,112 | 7 | 0 | 2008-08-30T00:10:12.480000 | 2008-08-30T02:18:30.957000 |
35,499 | 35,513 | Chat application AJAX polling | In the project I am currently working on, we have the need to develop a web chat application, not a very complex chat, just a way to connect two people to talk about a very specific topic, we don't need any kind of authentication for one of the two users, we don't have to support emoticons, avatars, or stuff like that. Some project members suggested that we could use XMPP through BOSH, I said that is like trying to catch a fish with a boat's net, and proposed a simpler method, like a simple Ajax/MySQL web chat, but we're worried about the performance hit in the server because of the constant polling of many chats open at the same time. Has anyone done something like this before? What would you recommend? | You might also want to look into Comet. It's used by GTalk, Meebo, and many other chat applications. A few years ago when I was experimenting with it, there weren't very many libraries or details about server architecture to implement it, but it looks like there is a lot more stuff out now. Have a look at the cometd project for more technical information. | Chat application AJAX polling In the project I am currently working on, we have the need to develop a web chat application, not a very complex chat, just a way to connect two people to talk about a very specific topic, we don't need any kind of authentication for one of the two users, we don't have to support emoticons, avatars, or stuff like that. Some project members suggested that we could use XMPP through BOSH, I said that is like trying to catch a fish with a boat's net, and proposed a simpler method, like a simple Ajax/MySQL web chat, but we're worried about the performance hit in the server because of the constant polling of many chats open at the same time. Has anyone done something like this before? What would you recommend? | TITLE:
Chat application AJAX polling
QUESTION:
In the project I am currently working on, we have the need to develop a web chat application, not a very complex chat, just a way to connect two people to talk about a very specific topic, we don't need any kind of authentication for one of the two users, we don't have to support emoticons, avatars, or stuff like that. Some project members suggested that we could use XMPP through BOSH, I said that is like trying to catch a fish with a boat's net, and proposed a simpler method, like a simple Ajax/MySQL web chat, but we're worried about the performance hit in the server because of the constant polling of many chats open at the same time. Has anyone done something like this before? What would you recommend?
ANSWER:
You might also want to look into Comet. It's used by GTalk, Meebo, and many other chat applications. A few years ago when I was experimenting with it, there weren't very many libraries or details about server architecture to implement it, but it looks like there is a lot more stuff out now. Have a look at the cometd project for more technical information. | [
"php",
"ajax",
"chat"
] | 14 | 7 | 6,092 | 12 | 0 | 2008-08-30T00:14:19.227000 | 2008-08-30T00:29:37.490000 |
35,507 | 234,746 | Changing default file structure in a Java Struts App | I have been working with Struts for some time, but for a project I am finishing I was asked to separate Templates (velocity.vm files), configs (struts.xml, persistence.xml) from main WAR file. I have all in default structure like: application |-- META-INF -- Some configs are here |-- WEB-INF -- others here | |-- classes | | |-- META-INF | | `-- mypackage | | `-- class-files | `-- lib |-- css `-- tpl -- Template dir to be relocated And I apparently can't find documentation about how to setup (probably in struts.xml) where my templates go, and where config files will be. I think I will have to use configurations on the application server too (I am using Jetty 5.1.14). So, any lights on how to configure it? Thanks Well, the whole thing about changing templates place is to put the templates in a designer accessible area, so any modification needed, the designer can load them to his/her computer, edit, and upload it again. I think this is a common scenario. So, probably I am missing something in my research. Maybe I am focusing in configuring it on the wrong place... Any thoughts? | If I understood your question about Struts config files right, they are specified in web.xml. Find the Struts servlet config param. The param-value can be a list of comma separated list of XML files to load. Eg: action org.apache.struts.action.ActionServlet config WEB-INF/config/struts-config.xml, WEB-INF/config/struts-config-stuff.xml, WEB-INF/config/struts-config-good.xml, WEB-INF/config/struts-config-bad.xml, WEB-INF/config/struts-config-ugly.xml... See this Struts guide under 5.3.2. And yes, this applies to 2.x also. | Changing default file structure in a Java Struts App I have been working with Struts for some time, but for a project I am finishing I was asked to separate Templates (velocity.vm files), configs (struts.xml, persistence.xml) from main WAR file. I have all in default structure like: application |-- META-INF -- Some configs are here |-- WEB-INF -- others here | |-- classes | | |-- META-INF | | `-- mypackage | | `-- class-files | `-- lib |-- css `-- tpl -- Template dir to be relocated And I apparently can't find documentation about how to setup (probably in struts.xml) where my templates go, and where config files will be. I think I will have to use configurations on the application server too (I am using Jetty 5.1.14). So, any lights on how to configure it? Thanks Well, the whole thing about changing templates place is to put the templates in a designer accessible area, so any modification needed, the designer can load them to his/her computer, edit, and upload it again. I think this is a common scenario. So, probably I am missing something in my research. Maybe I am focusing in configuring it on the wrong place... Any thoughts? | TITLE:
Changing default file structure in a Java Struts App
QUESTION:
I have been working with Struts for some time, but for a project I am finishing I was asked to separate Templates (velocity.vm files), configs (struts.xml, persistence.xml) from main WAR file. I have all in default structure like: application |-- META-INF -- Some configs are here |-- WEB-INF -- others here | |-- classes | | |-- META-INF | | `-- mypackage | | `-- class-files | `-- lib |-- css `-- tpl -- Template dir to be relocated And I apparently can't find documentation about how to setup (probably in struts.xml) where my templates go, and where config files will be. I think I will have to use configurations on the application server too (I am using Jetty 5.1.14). So, any lights on how to configure it? Thanks Well, the whole thing about changing templates place is to put the templates in a designer accessible area, so any modification needed, the designer can load them to his/her computer, edit, and upload it again. I think this is a common scenario. So, probably I am missing something in my research. Maybe I am focusing in configuring it on the wrong place... Any thoughts?
ANSWER:
If I understood your question about Struts config files right, they are specified in web.xml. Find the Struts servlet config param. The param-value can be a list of comma separated list of XML files to load. Eg: action org.apache.struts.action.ActionServlet config WEB-INF/config/struts-config.xml, WEB-INF/config/struts-config-stuff.xml, WEB-INF/config/struts-config-good.xml, WEB-INF/config/struts-config-bad.xml, WEB-INF/config/struts-config-ugly.xml... See this Struts guide under 5.3.2. And yes, this applies to 2.x also. | [
"java",
"templates",
"struts",
"configuration-files"
] | 3 | 1 | 1,021 | 3 | 0 | 2008-08-30T00:19:14.877000 | 2008-10-24T18:27:11.583000 |
35,522 | 35,524 | looping and average in c++ | Programming Student here...trying to work on a project but I'm stuck. The project is trying to find the miles per gallon per trip then at the end outputting total miles and total gallons used and averaging miles per gallon How do I loop back up to the first question after the first set of questions has been asked. Also how will I average the trips...will I have to have a variable for each of the trips? I'm stuck, any help would be great! | You will have to tell us the type of data you are given. As per your last question: remember that an average can be calculated in real time by either storing the sum and the number of data points (two numbers), or the current average and the number of data points (again, two numbers). For instance: class Averager { double avg; int n; public: Averager(): avg(0), n(0) {} void addPoint(double v) { avg = (n * avg + v) / (n + 1); n++; } double average() const { return avg; } }; | looping and average in c++ Programming Student here...trying to work on a project but I'm stuck. The project is trying to find the miles per gallon per trip then at the end outputting total miles and total gallons used and averaging miles per gallon How do I loop back up to the first question after the first set of questions has been asked. Also how will I average the trips...will I have to have a variable for each of the trips? I'm stuck, any help would be great! | TITLE:
looping and average in c++
QUESTION:
Programming Student here...trying to work on a project but I'm stuck. The project is trying to find the miles per gallon per trip then at the end outputting total miles and total gallons used and averaging miles per gallon How do I loop back up to the first question after the first set of questions has been asked. Also how will I average the trips...will I have to have a variable for each of the trips? I'm stuck, any help would be great!
ANSWER:
You will have to tell us the type of data you are given. As per your last question: remember that an average can be calculated in real time by either storing the sum and the number of data points (two numbers), or the current average and the number of data points (again, two numbers). For instance: class Averager { double avg; int n; public: Averager(): avg(0), n(0) {} void addPoint(double v) { avg = (n * avg + v) / (n + 1); n++; } double average() const { return avg; } }; | [
"c++"
] | 0 | 2 | 1,218 | 1 | 0 | 2008-08-30T00:44:43.180000 | 2008-08-30T00:47:12.377000 |
35,530 | 35,531 | What Are High-Pass and Low-Pass Filters? | Graphics and audio editing and processing software often contain functions called "High-Pass Filter" and "Low-Pass Filter". Exactly what do these do, and what are the algorithms for implementing them? | Wikipedia: High-pass filter Low-pass filter Band-pass filter These "high", "low", and "band" terms refer to frequencies. In high-pass, you try to remove low frequencies. In low-pass, you try to remove high. In band pass, you only allow a continuous frequency range to remain. Choosing the cut-off frequency depends upon your application. Coding these filters can either be done by simulating RC circuits or by playing around with Fourier transforms of your time-based data. See the wikipedia articles for code examples. | What Are High-Pass and Low-Pass Filters? Graphics and audio editing and processing software often contain functions called "High-Pass Filter" and "Low-Pass Filter". Exactly what do these do, and what are the algorithms for implementing them? | TITLE:
What Are High-Pass and Low-Pass Filters?
QUESTION:
Graphics and audio editing and processing software often contain functions called "High-Pass Filter" and "Low-Pass Filter". Exactly what do these do, and what are the algorithms for implementing them?
ANSWER:
Wikipedia: High-pass filter Low-pass filter Band-pass filter These "high", "low", and "band" terms refer to frequencies. In high-pass, you try to remove low frequencies. In low-pass, you try to remove high. In band pass, you only allow a continuous frequency range to remain. Choosing the cut-off frequency depends upon your application. Coding these filters can either be done by simulating RC circuits or by playing around with Fourier transforms of your time-based data. See the wikipedia articles for code examples. | [
"algorithm",
"graphics",
"audio",
"photoshop",
"signal-processing"
] | 27 | 22 | 86,821 | 6 | 0 | 2008-08-30T00:55:26.053000 | 2008-08-30T00:58:00.027000 |
35,537 | 35,665 | Zoom for a windows form in C# | Is there an easy way to set the zoom level for a windows form in C#? In VBA there was a zoom property of the form. | There is no way (that I know of) to do what you ask with typical WinForms. If you're doing custom painting/drawing, you can zoom that by using a zoom transform, but so far as I know there is no "Zoom" property for the form in the entire world of.NET and native Windows/C++ APIs combined. You could probably rig something yourself such that you scale controls by a constant factor. And you can probably find 3rd-party controls/surfaces which support this. And who knows what is possible with WPF. But in a typical WinForms world, no. | Zoom for a windows form in C# Is there an easy way to set the zoom level for a windows form in C#? In VBA there was a zoom property of the form. | TITLE:
Zoom for a windows form in C#
QUESTION:
Is there an easy way to set the zoom level for a windows form in C#? In VBA there was a zoom property of the form.
ANSWER:
There is no way (that I know of) to do what you ask with typical WinForms. If you're doing custom painting/drawing, you can zoom that by using a zoom transform, but so far as I know there is no "Zoom" property for the form in the entire world of.NET and native Windows/C++ APIs combined. You could probably rig something yourself such that you scale controls by a constant factor. And you can probably find 3rd-party controls/surfaces which support this. And who knows what is possible with WPF. But in a typical WinForms world, no. | [
"c#",
"winforms"
] | 11 | 0 | 36,456 | 3 | 0 | 2008-08-30T01:11:46.937000 | 2008-08-30T03:55:38.413000 |
35,538 | 35,543 | Validate (X)HTML in Python | What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. | XHTML is easy, use lxml. from lxml import etree from StringIO import StringIO etree.parse(StringIO(html), etree.HTMLParser(recover=False)) HTML is harder, since there's traditionally not been as much interest in validation among the HTML crowd (run StackOverflow itself through a validator, yikes). The easiest solution would be to execute external applications such as nsgmls or OpenJade, and then parse their output. | Validate (X)HTML in Python What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app. | TITLE:
Validate (X)HTML in Python
QUESTION:
What's the best way to go about validating that a document follows some version of HTML (prefereably that I can specify)? I'd like to be able to know where the failures occur, as in a web-based validator, except in a native Python app.
ANSWER:
XHTML is easy, use lxml. from lxml import etree from StringIO import StringIO etree.parse(StringIO(html), etree.HTMLParser(recover=False)) HTML is harder, since there's traditionally not been as much interest in validation among the HTML crowd (run StackOverflow itself through a validator, yikes). The easiest solution would be to execute external applications such as nsgmls or OpenJade, and then parse their output. | [
"python",
"html",
"validation",
"xhtml"
] | 45 | 19 | 30,074 | 9 | 0 | 2008-08-30T01:15:32.370000 | 2008-08-30T01:20:52.157000 |
35,541 | 145,362 | Are there any good programs for actionscript/flex that'll count lines of code, number of functions, files, packages,etc | Doug McCune had created something that was exactly what I needed ( http://dougmccune.com/blog/2007/05/10/analyze-your-actionscript-code-with-this-apollo-app/ ) but alas - it was for AIR beta 2. I just would like some tool that I can run that would provide some decent metrics...any idea's? | There is a Code Metrics Explorer in the Enterprise Flex Plug-in below: http://www.deitte.com/archives/2008/09/flex_builder_pl.htm | Are there any good programs for actionscript/flex that'll count lines of code, number of functions, files, packages,etc Doug McCune had created something that was exactly what I needed ( http://dougmccune.com/blog/2007/05/10/analyze-your-actionscript-code-with-this-apollo-app/ ) but alas - it was for AIR beta 2. I just would like some tool that I can run that would provide some decent metrics...any idea's? | TITLE:
Are there any good programs for actionscript/flex that'll count lines of code, number of functions, files, packages,etc
QUESTION:
Doug McCune had created something that was exactly what I needed ( http://dougmccune.com/blog/2007/05/10/analyze-your-actionscript-code-with-this-apollo-app/ ) but alas - it was for AIR beta 2. I just would like some tool that I can run that would provide some decent metrics...any idea's?
ANSWER:
There is a Code Metrics Explorer in the Enterprise Flex Plug-in below: http://www.deitte.com/archives/2008/09/flex_builder_pl.htm | [
"apache-flex",
"actionscript-3",
"code-analysis"
] | 2 | 3 | 4,170 | 6 | 0 | 2008-08-30T01:17:52.100000 | 2008-09-28T06:39:07.227000 |
35,548 | 35,592 | Make source with two targets | I use this tool called Lazy C++ which breaks a single C++.lzz file into a.h and.cpp file. I want Makepp to expect both of these files to exist after my rule for building.lzz files, but I'm not sure how to put two targets into a single build line. | I've never used Makepp personally, but since it's a drop-in replacement for GNU Make, you should be able to do something like: build: foo.h foo.cpp g++ $(CFLAGS) foo.cpp -o $(LFLAGS) foo
foo.h foo.cpp: foo.lzz lzz foo.lzz Also not sure about the lzz invocation there, but that should help. You can read more about this at http://theory.uwinnipeg.ca/gnu/make/make_37.html. | Make source with two targets I use this tool called Lazy C++ which breaks a single C++.lzz file into a.h and.cpp file. I want Makepp to expect both of these files to exist after my rule for building.lzz files, but I'm not sure how to put two targets into a single build line. | TITLE:
Make source with two targets
QUESTION:
I use this tool called Lazy C++ which breaks a single C++.lzz file into a.h and.cpp file. I want Makepp to expect both of these files to exist after my rule for building.lzz files, but I'm not sure how to put two targets into a single build line.
ANSWER:
I've never used Makepp personally, but since it's a drop-in replacement for GNU Make, you should be able to do something like: build: foo.h foo.cpp g++ $(CFLAGS) foo.cpp -o $(LFLAGS) foo
foo.h foo.cpp: foo.lzz lzz foo.lzz Also not sure about the lzz invocation there, but that should help. You can read more about this at http://theory.uwinnipeg.ca/gnu/make/make_37.html. | [
"build-process",
"makefile",
"lazy-c++"
] | 2 | 3 | 448 | 2 | 0 | 2008-08-30T01:26:42.203000 | 2008-08-30T02:10:19.930000 |
35,551 | 35,556 | Excluding Code Analysis rule in source | In a project I'm working on FxCop shows me lots of (and I mean more than 400) errors on the InitializeComponent() methods generated by the Windows Forms designer. Most of those errors are just the assignment of the Text property of labels. I'd like to suppress those methods in source, so I copied the suppression code generated by FxCop into AssemblyInfo.cs, but it doesn't work. This is the attribute that FxCop copied to the clipboard. [module: SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Scope = "member", Target = "WindowsClient.MainForm.InitializeComponent():System.Void", MessageId = "System.Windows.Forms.Control.set_Text(System.String)")] Anyone knows the correct attribute to suppress this messages? PS: I'm using Visual Studio 2005, C#, FxCop 1.36 beta. | You've probably got the right code, but you also need to add CODE_ANALYSIS as a precompiler defined symbol in the project properties. I think those SuppressMessage attributes are only left in the compiled binaries if CODE_ANALYSIS is defined. | Excluding Code Analysis rule in source In a project I'm working on FxCop shows me lots of (and I mean more than 400) errors on the InitializeComponent() methods generated by the Windows Forms designer. Most of those errors are just the assignment of the Text property of labels. I'd like to suppress those methods in source, so I copied the suppression code generated by FxCop into AssemblyInfo.cs, but it doesn't work. This is the attribute that FxCop copied to the clipboard. [module: SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Scope = "member", Target = "WindowsClient.MainForm.InitializeComponent():System.Void", MessageId = "System.Windows.Forms.Control.set_Text(System.String)")] Anyone knows the correct attribute to suppress this messages? PS: I'm using Visual Studio 2005, C#, FxCop 1.36 beta. | TITLE:
Excluding Code Analysis rule in source
QUESTION:
In a project I'm working on FxCop shows me lots of (and I mean more than 400) errors on the InitializeComponent() methods generated by the Windows Forms designer. Most of those errors are just the assignment of the Text property of labels. I'd like to suppress those methods in source, so I copied the suppression code generated by FxCop into AssemblyInfo.cs, but it doesn't work. This is the attribute that FxCop copied to the clipboard. [module: SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", Scope = "member", Target = "WindowsClient.MainForm.InitializeComponent():System.Void", MessageId = "System.Windows.Forms.Control.set_Text(System.String)")] Anyone knows the correct attribute to suppress this messages? PS: I'm using Visual Studio 2005, C#, FxCop 1.36 beta.
ANSWER:
You've probably got the right code, but you also need to add CODE_ANALYSIS as a precompiler defined symbol in the project properties. I think those SuppressMessage attributes are only left in the compiled binaries if CODE_ANALYSIS is defined. | [
"visual-studio",
"code-analysis",
"fxcop",
"suppression",
"initializecomponent"
] | 19 | 18 | 6,722 | 3 | 0 | 2008-08-30T01:29:05.617000 | 2008-08-30T01:37:11.273000 |
35,559 | 35,578 | How far does SQL Server Express Edition scale? | Wikipedia says SQL Server Express Edition is limited to "one processor, 1 GB memory and 4 GB database files". Does anyone have practical experience with how well this scales? | It's a regular sql server, it just has a limit. SharePoint by default uses the sql server express if that gives you any idea. We have our entire office (80+) people running on that instance. | How far does SQL Server Express Edition scale? Wikipedia says SQL Server Express Edition is limited to "one processor, 1 GB memory and 4 GB database files". Does anyone have practical experience with how well this scales? | TITLE:
How far does SQL Server Express Edition scale?
QUESTION:
Wikipedia says SQL Server Express Edition is limited to "one processor, 1 GB memory and 4 GB database files". Does anyone have practical experience with how well this scales?
ANSWER:
It's a regular sql server, it just has a limit. SharePoint by default uses the sql server express if that gives you any idea. We have our entire office (80+) people running on that instance. | [
"sql-server-express"
] | 2 | 5 | 1,348 | 4 | 0 | 2008-08-30T01:44:34.347000 | 2008-08-30T02:00:04.700000 |
35,560 | 36,348 | Lazy Loading with a WCF Service Domain Model? | I'm looking to push my domain model into a WCF Service API and wanted to get some thoughts on lazy loading techniques with this type of setup. Any suggestions when taking this approach? when I implemented this technique and step into my app, just before the server returns my list it hits the get of each property that is supposed to be lazy loaded... Thus eager loading. Could you explain this issue or suggest a resolution? Edit: It appears you can use the XMLIgnore attribute so it doesn’t get looked at during serialization.. still reading up on this though | As for any remoting architecture, you'll want to avoid loading a full object graph "down the wire" in an uncontrolled way (unless you have a trivially small number of objects). The Wikipedia article has the standard techniques pretty much summarised (and in C#. too!). I've used both ghosts and value holders and they work pretty well. To implement this kind of technique, make sure that you separate concerns strictly. On the server, your service contract implementation classes should be the only bits of the code that work with data contracts. On the client, the service access layer should be the only code that works with the proxies. Layering like this lets you adjust the way that the service is implemented relatively independently of the UI layers calling the service and the business tier that's being called. It also gives you half a chance of unit testing! | Lazy Loading with a WCF Service Domain Model? I'm looking to push my domain model into a WCF Service API and wanted to get some thoughts on lazy loading techniques with this type of setup. Any suggestions when taking this approach? when I implemented this technique and step into my app, just before the server returns my list it hits the get of each property that is supposed to be lazy loaded... Thus eager loading. Could you explain this issue or suggest a resolution? Edit: It appears you can use the XMLIgnore attribute so it doesn’t get looked at during serialization.. still reading up on this though | TITLE:
Lazy Loading with a WCF Service Domain Model?
QUESTION:
I'm looking to push my domain model into a WCF Service API and wanted to get some thoughts on lazy loading techniques with this type of setup. Any suggestions when taking this approach? when I implemented this technique and step into my app, just before the server returns my list it hits the get of each property that is supposed to be lazy loaded... Thus eager loading. Could you explain this issue or suggest a resolution? Edit: It appears you can use the XMLIgnore attribute so it doesn’t get looked at during serialization.. still reading up on this though
ANSWER:
As for any remoting architecture, you'll want to avoid loading a full object graph "down the wire" in an uncontrolled way (unless you have a trivially small number of objects). The Wikipedia article has the standard techniques pretty much summarised (and in C#. too!). I've used both ghosts and value holders and they work pretty well. To implement this kind of technique, make sure that you separate concerns strictly. On the server, your service contract implementation classes should be the only bits of the code that work with data contracts. On the client, the service access layer should be the only code that works with the proxies. Layering like this lets you adjust the way that the service is implemented relatively independently of the UI layers calling the service and the business tier that's being called. It also gives you half a chance of unit testing! | [
"wcf",
"web-services",
"domain-driven-design"
] | 6 | 3 | 3,799 | 3 | 0 | 2008-08-30T01:46:19.630000 | 2008-08-30T21:16:51.627000 |
35,563 | 464,168 | How do I make bash reverse-search work in Terminal.app without it displaying garbled output? | Using Terminal.app on OS X 10.5, often you see the commands get garbled when you do a reverse-search with Bash. Is there some kind of termcap or perhaps a bash shopt command that can fix this? It is very annoying. Steps to reproduce: Open Terminal.app, reverse-search to a longish command. Hit -E once you've found the command. The cursor goes to the end of the line, but the display doesn't update. I'm guessing this is some kind of problem with the readline library on OS X. It's more of a problem with updating the cursor position after a search than anything else. Basically, ctrl-a and ctrl-e tend to break the search output. os x terminal failure image http://involution.com/images/osxterminal.png In the above, the first part of the command should be displayed, and the cursor should be at the end of the line, but it isn't. You literally can't see what you're editing when this happens. | I was able to set my TERM to xterm instead of xterm-color and it solves the problem. (export TERM=xterm). | How do I make bash reverse-search work in Terminal.app without it displaying garbled output? Using Terminal.app on OS X 10.5, often you see the commands get garbled when you do a reverse-search with Bash. Is there some kind of termcap or perhaps a bash shopt command that can fix this? It is very annoying. Steps to reproduce: Open Terminal.app, reverse-search to a longish command. Hit -E once you've found the command. The cursor goes to the end of the line, but the display doesn't update. I'm guessing this is some kind of problem with the readline library on OS X. It's more of a problem with updating the cursor position after a search than anything else. Basically, ctrl-a and ctrl-e tend to break the search output. os x terminal failure image http://involution.com/images/osxterminal.png In the above, the first part of the command should be displayed, and the cursor should be at the end of the line, but it isn't. You literally can't see what you're editing when this happens. | TITLE:
How do I make bash reverse-search work in Terminal.app without it displaying garbled output?
QUESTION:
Using Terminal.app on OS X 10.5, often you see the commands get garbled when you do a reverse-search with Bash. Is there some kind of termcap or perhaps a bash shopt command that can fix this? It is very annoying. Steps to reproduce: Open Terminal.app, reverse-search to a longish command. Hit -E once you've found the command. The cursor goes to the end of the line, but the display doesn't update. I'm guessing this is some kind of problem with the readline library on OS X. It's more of a problem with updating the cursor position after a search than anything else. Basically, ctrl-a and ctrl-e tend to break the search output. os x terminal failure image http://involution.com/images/osxterminal.png In the above, the first part of the command should be displayed, and the cursor should be at the end of the line, but it isn't. You literally can't see what you're editing when this happens.
ANSWER:
I was able to set my TERM to xterm instead of xterm-color and it solves the problem. (export TERM=xterm). | [
"macos",
"bash"
] | 9 | 11 | 4,292 | 7 | 0 | 2008-08-30T01:48:42.260000 | 2009-01-21T05:24:25.750000 |
35,569 | 35,582 | Why does Python's iter() on a mapping return iterkeys() instead of iteritems()? | It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this? | Check out this thread for a discussion on the reasons behind this behavior (including that Guido likes it, and it's not likely to change ). | Why does Python's iter() on a mapping return iterkeys() instead of iteritems()? It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this? | TITLE:
Why does Python's iter() on a mapping return iterkeys() instead of iteritems()?
QUESTION:
It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this?
ANSWER:
Check out this thread for a discussion on the reasons behind this behavior (including that Guido likes it, and it's not likely to change ). | [
"python",
"mapping",
"iteration"
] | 13 | 13 | 849 | 1 | 0 | 2008-08-30T01:51:05.187000 | 2008-08-30T02:01:57.143000 |
35,615 | 35,632 | What is a good online resource for css 'design patterns'? | Can anyone out there recommend a good online resource for CSS 'design patterns'? I know design patterns in a software context usually refer to OO based design patterns, but I mean design patterns in the broader sense of the term: i.e. common, clean solutions to common problems / tasks. An example of such a resource would be this list of table designs, this gives you all you really need to know about how to make tables look nice using a set of CSS techniques. Other examples of common problems which could have nice set solutions would be things like rounded corners on divs, highly usable form layouts etc. | I refer to A List Apart articles all the time for those sorts of things. They do a lot of trial-and-error research to come up with really creative ways to handle those common CSS problems in the cleanest most portable way possible. | What is a good online resource for css 'design patterns'? Can anyone out there recommend a good online resource for CSS 'design patterns'? I know design patterns in a software context usually refer to OO based design patterns, but I mean design patterns in the broader sense of the term: i.e. common, clean solutions to common problems / tasks. An example of such a resource would be this list of table designs, this gives you all you really need to know about how to make tables look nice using a set of CSS techniques. Other examples of common problems which could have nice set solutions would be things like rounded corners on divs, highly usable form layouts etc. | TITLE:
What is a good online resource for css 'design patterns'?
QUESTION:
Can anyone out there recommend a good online resource for CSS 'design patterns'? I know design patterns in a software context usually refer to OO based design patterns, but I mean design patterns in the broader sense of the term: i.e. common, clean solutions to common problems / tasks. An example of such a resource would be this list of table designs, this gives you all you really need to know about how to make tables look nice using a set of CSS techniques. Other examples of common problems which could have nice set solutions would be things like rounded corners on divs, highly usable form layouts etc.
ANSWER:
I refer to A List Apart articles all the time for those sorts of things. They do a lot of trial-and-error research to come up with really creative ways to handle those common CSS problems in the cleanest most portable way possible. | [
"html",
"css",
"design-patterns",
"xhtml"
] | 20 | 3 | 10,687 | 5 | 0 | 2008-08-30T02:42:38.560000 | 2008-08-30T03:01:03.867000 |
35,634 | 35,635 | Ruby "is" equivalent | Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location). | Use a.equal? b http://www.ruby-doc.org/core/classes/Object.html Unlike ==, the equal? method should never be overridden by subclasses: it is used to determine object identity (that is, a.equal?(b) iff a is the same object as b). | Ruby "is" equivalent Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location). | TITLE:
Ruby "is" equivalent
QUESTION:
Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location).
ANSWER:
Use a.equal? b http://www.ruby-doc.org/core/classes/Object.html Unlike ==, the equal? method should never be overridden by subclasses: it is used to determine object identity (that is, a.equal?(b) iff a is the same object as b). | [
"python",
"ruby"
] | 9 | 13 | 507 | 2 | 0 | 2008-08-30T03:04:54.527000 | 2008-08-30T03:06:02.310000 |
35,646 | 35,690 | Do you continue development in a branch or in the trunk? | Suppose you're developing a software product that has periodic releases. What are the best practices with regard to branching and merging? Slicing off periodic release branches to the public (or whomever your customer is) and then continuing development on the trunk, or considering the trunk the stable version, tagging it as a release periodically, and doing your experimental work in branches. What do folks think is the trunk considered "gold" or considered a "sand box"? | I have tried both methods with a large commercial application. The answer to which method is better is highly dependent on your exact situation, but I will write what my overall experience has shown so far. The better method overall (in my experience): The trunk should be always stable. Here are some guidelines and benefits of this method: Code each task (or related set of tasks) in its own branch, then you will have the flexibility of when you would like to merge these tasks and perform a release. QA should be done on each branch before it is merged to the trunk. By doing QA on each individual branch, you will know exactly what caused the bug easier. This solution scales to any number of developers. This method works since branching is an almost instant operation in SVN. Tag each release that you perform. You can develop features that you don't plan to release for a while and decide exactly when to merge them. For all work you do, you can have the benefit of committing your code. If you work out of the trunk only, you will probably keep your code uncommitted a lot, and hence unprotected and without automatic history. If you try to do the opposite and do all your development in the trunk you'll have the following issues: Constant build problems for daily builds Productivity loss when a a developer commits a problem for all other people on the project Longer release cycles, because you need to finally get a stable version Less stable releases You simply will not have the flexibility that you need if you try to keep a branch stable and the trunk as the development sandbox. The reason is that you can't pick and chose from the trunk what you want to put in that stable release. It would already be all mixed in together in the trunk. The one case in particular that I would say to do all development in the trunk, is when you are starting a new project. There may be other cases too depending on your situation. By the way distributed version control systems provide much more flexibility and I highly recommend switching to either hg or git. | Do you continue development in a branch or in the trunk? Suppose you're developing a software product that has periodic releases. What are the best practices with regard to branching and merging? Slicing off periodic release branches to the public (or whomever your customer is) and then continuing development on the trunk, or considering the trunk the stable version, tagging it as a release periodically, and doing your experimental work in branches. What do folks think is the trunk considered "gold" or considered a "sand box"? | TITLE:
Do you continue development in a branch or in the trunk?
QUESTION:
Suppose you're developing a software product that has periodic releases. What are the best practices with regard to branching and merging? Slicing off periodic release branches to the public (or whomever your customer is) and then continuing development on the trunk, or considering the trunk the stable version, tagging it as a release periodically, and doing your experimental work in branches. What do folks think is the trunk considered "gold" or considered a "sand box"?
ANSWER:
I have tried both methods with a large commercial application. The answer to which method is better is highly dependent on your exact situation, but I will write what my overall experience has shown so far. The better method overall (in my experience): The trunk should be always stable. Here are some guidelines and benefits of this method: Code each task (or related set of tasks) in its own branch, then you will have the flexibility of when you would like to merge these tasks and perform a release. QA should be done on each branch before it is merged to the trunk. By doing QA on each individual branch, you will know exactly what caused the bug easier. This solution scales to any number of developers. This method works since branching is an almost instant operation in SVN. Tag each release that you perform. You can develop features that you don't plan to release for a while and decide exactly when to merge them. For all work you do, you can have the benefit of committing your code. If you work out of the trunk only, you will probably keep your code uncommitted a lot, and hence unprotected and without automatic history. If you try to do the opposite and do all your development in the trunk you'll have the following issues: Constant build problems for daily builds Productivity loss when a a developer commits a problem for all other people on the project Longer release cycles, because you need to finally get a stable version Less stable releases You simply will not have the flexibility that you need if you try to keep a branch stable and the trunk as the development sandbox. The reason is that you can't pick and chose from the trunk what you want to put in that stable release. It would already be all mixed in together in the trunk. The one case in particular that I would say to do all development in the trunk, is when you are starting a new project. There may be other cases too depending on your situation. By the way distributed version control systems provide much more flexibility and I highly recommend switching to either hg or git. | [
"version-control"
] | 171 | 152 | 48,583 | 20 | 0 | 2008-08-30T03:26:11.450000 | 2008-08-30T05:01:59.847000 |
35,669 | 35,692 | Windows Home Server versus Vista Backup and Restore Center | I've been using Window Home Server for my backups here at home for most of a year now, and I'm really pleased with it. It's far better than the software I was using previously (Acronis). I'm thinking about a backup strategy for my work machine and I'd like to know how WHS compares with Vista's built-in backup and restore features. The plan is to do a full backup to a local external hard drive and backup the documents folder to a network drive on the server. Anyone have experience using the Vista backup feature like this? | Chris, They're different beasts. WHS backup is pretty much automatic and uses deltas - Vista's is manual and I don't believe offers incremental updates. While your solution (Vista + network copy) would preserve your data it has two problems I an see; Your documents will only have the latest revision. If you find something was corrupted a month ago it could be very awkward to recover it. Vista's shadow copies may help though. As soon as you install a program/patch/config your Vista backup is out of date and needs remade, or these repeated if you reinstall. These might not be dealbreakers and indeed Vista's backup is pretty decent, it's just nowhere near as good as WHS. In my opinion WHS leaves almost everything else standing, you can be sure this tech will be in the "big brother" server versions shortly. | Windows Home Server versus Vista Backup and Restore Center I've been using Window Home Server for my backups here at home for most of a year now, and I'm really pleased with it. It's far better than the software I was using previously (Acronis). I'm thinking about a backup strategy for my work machine and I'd like to know how WHS compares with Vista's built-in backup and restore features. The plan is to do a full backup to a local external hard drive and backup the documents folder to a network drive on the server. Anyone have experience using the Vista backup feature like this? | TITLE:
Windows Home Server versus Vista Backup and Restore Center
QUESTION:
I've been using Window Home Server for my backups here at home for most of a year now, and I'm really pleased with it. It's far better than the software I was using previously (Acronis). I'm thinking about a backup strategy for my work machine and I'd like to know how WHS compares with Vista's built-in backup and restore features. The plan is to do a full backup to a local external hard drive and backup the documents folder to a network drive on the server. Anyone have experience using the Vista backup feature like this?
ANSWER:
Chris, They're different beasts. WHS backup is pretty much automatic and uses deltas - Vista's is manual and I don't believe offers incremental updates. While your solution (Vista + network copy) would preserve your data it has two problems I an see; Your documents will only have the latest revision. If you find something was corrupted a month ago it could be very awkward to recover it. Vista's shadow copies may help though. As soon as you install a program/patch/config your Vista backup is out of date and needs remade, or these repeated if you reinstall. These might not be dealbreakers and indeed Vista's backup is pretty decent, it's just nowhere near as good as WHS. In my opinion WHS leaves almost everything else standing, you can be sure this tech will be in the "big brother" server versions shortly. | [
"backup",
"windows-vista"
] | 1 | 4 | 1,980 | 4 | 0 | 2008-08-30T04:01:53.860000 | 2008-08-30T05:05:39.137000 |
35,670 | 35,672 | How do I begin using SVN? | I am ready to start using SVN, but I have NO (as in the money required for free beer) experience with source control. I have installed subversion on my server (that was easy, 'apt-get install subversion') but now I don't know what to do, how to configure it, or how to use it. What suggestions do you have, and where can I find good resources to learn to start using it? Update: O.K. So the feedback has been great and I have read through a bit of it but I want to clarify my question by saying that I am looking for more information on how to actually go about setting my up my repositories, clients, server, etc. I know that I could do a quick Google search and find dozens (or more) resources but I'm hoping that someone whom has experience with subversion and a client(I have installed tortoise) could suggest a good reference that will be reliable, and have quality content. | Eric Sink has an excellent series on source code control aimed at beginners. For Subversion specifics, including setting up and administering a server, the Subversion book is a great resource, and includes a section with examples of a typical session with Subversion (checkout, commit, merging and updating basics). Update: I forgot to mention that for beginners, I'd also recommend messing around in a graphical client, which removes the command-line hassle from the learning experience. RapidSVN is a reasonable cross-platform client. You'll also find that common IDEs either come with Subversion support, or have plugins which can be installed, which allow most version control operations to be performed within that environment. @John Millikin: While setting up a Subversion server can be complicated, depending on one's general admin experience, don't forget that you don't need to do that just to mess about with a repository and get to grips with the basics - the client can interact with a repository in the local filesystem. | How do I begin using SVN? I am ready to start using SVN, but I have NO (as in the money required for free beer) experience with source control. I have installed subversion on my server (that was easy, 'apt-get install subversion') but now I don't know what to do, how to configure it, or how to use it. What suggestions do you have, and where can I find good resources to learn to start using it? Update: O.K. So the feedback has been great and I have read through a bit of it but I want to clarify my question by saying that I am looking for more information on how to actually go about setting my up my repositories, clients, server, etc. I know that I could do a quick Google search and find dozens (or more) resources but I'm hoping that someone whom has experience with subversion and a client(I have installed tortoise) could suggest a good reference that will be reliable, and have quality content. | TITLE:
How do I begin using SVN?
QUESTION:
I am ready to start using SVN, but I have NO (as in the money required for free beer) experience with source control. I have installed subversion on my server (that was easy, 'apt-get install subversion') but now I don't know what to do, how to configure it, or how to use it. What suggestions do you have, and where can I find good resources to learn to start using it? Update: O.K. So the feedback has been great and I have read through a bit of it but I want to clarify my question by saying that I am looking for more information on how to actually go about setting my up my repositories, clients, server, etc. I know that I could do a quick Google search and find dozens (or more) resources but I'm hoping that someone whom has experience with subversion and a client(I have installed tortoise) could suggest a good reference that will be reliable, and have quality content.
ANSWER:
Eric Sink has an excellent series on source code control aimed at beginners. For Subversion specifics, including setting up and administering a server, the Subversion book is a great resource, and includes a section with examples of a typical session with Subversion (checkout, commit, merging and updating basics). Update: I forgot to mention that for beginners, I'd also recommend messing around in a graphical client, which removes the command-line hassle from the learning experience. RapidSVN is a reasonable cross-platform client. You'll also find that common IDEs either come with Subversion support, or have plugins which can be installed, which allow most version control operations to be performed within that environment. @John Millikin: While setting up a Subversion server can be complicated, depending on one's general admin experience, don't forget that you don't need to do that just to mess about with a repository and get to grips with the basics - the client can interact with a repository in the local filesystem. | [
"svn"
] | 17 | 17 | 3,866 | 8 | 0 | 2008-08-30T04:01:55.263000 | 2008-08-30T04:04:35.197000 |
35,677 | 36,212 | What is the best architecture to bridge to XMPP? | If I have a separate system with its own concept of users and presence, what is the most appropriate architecture for creating a bridge to an XMPP server network? As far as I can tell there are three primary ways: Act as a server. This creates one touchpoint, but I fear it has implications for compatibility, and potentially creates complexity in my system for emulating a server. Act as a clients. This seems to imply that I need one connection per user in my system, which just isn't going to scale well. I've heard of an XMPP gateway protocol, but it's unclear if this is any better than the client solution. I also can't tell if this is standard or not. Any suggestions or tradeoffs would be appreciated. For example, would any of these solutions require running code inside the target XMPP server (not likely something I can do). | The XMPP gateway protocol you've heard of is most likely to do with transports. A transport is a server that connects to both a XMPP server and a non-XMPP server. By running a transport, I can use my Jabber client to talk to someone using, say, MSN Messenger. A transport typically connects once to the remote network for each JID that it sees as online. That is, it's your option 2 in reverse. This is because there is no special relationship between the transport and the non-XMPP network; the transport is simply acting as a bunch of regular clients. For this to work, XMPP clients must first register with the transport, giving login credentials for the remote network, and allowing the transport to view their presence. The only reason this has a chance of scaling better is that there can be many transports for the same remote network. For example, my Jabber server could run a transport to MSN, another Jabber server could run another one, and so on, each one providing connections for a different subset of XMPP users. While this spreads out the load on the Jabber side, and load balancing on your system may spread out the load as well, it still requires many connections between the two systems. In your case, because (I assume) the non-XMPP side of things is cooperating, putting a XMPP server interface on the non-XMPP server is likely your best bet. That server interface is best suited for managing the mapping between XMPP JIDs and how that JID will appear on its own network, rather than forcing XMPP users to register and so on. In case you haven't seen these, you might find them useful: http://www.jabber.org/jabber-for-geeks/technology-overview http://www.xmpp.org/protocols/ http://www.xmpp.org/extensions/ Hope that helps. | What is the best architecture to bridge to XMPP? If I have a separate system with its own concept of users and presence, what is the most appropriate architecture for creating a bridge to an XMPP server network? As far as I can tell there are three primary ways: Act as a server. This creates one touchpoint, but I fear it has implications for compatibility, and potentially creates complexity in my system for emulating a server. Act as a clients. This seems to imply that I need one connection per user in my system, which just isn't going to scale well. I've heard of an XMPP gateway protocol, but it's unclear if this is any better than the client solution. I also can't tell if this is standard or not. Any suggestions or tradeoffs would be appreciated. For example, would any of these solutions require running code inside the target XMPP server (not likely something I can do). | TITLE:
What is the best architecture to bridge to XMPP?
QUESTION:
If I have a separate system with its own concept of users and presence, what is the most appropriate architecture for creating a bridge to an XMPP server network? As far as I can tell there are three primary ways: Act as a server. This creates one touchpoint, but I fear it has implications for compatibility, and potentially creates complexity in my system for emulating a server. Act as a clients. This seems to imply that I need one connection per user in my system, which just isn't going to scale well. I've heard of an XMPP gateway protocol, but it's unclear if this is any better than the client solution. I also can't tell if this is standard or not. Any suggestions or tradeoffs would be appreciated. For example, would any of these solutions require running code inside the target XMPP server (not likely something I can do).
ANSWER:
The XMPP gateway protocol you've heard of is most likely to do with transports. A transport is a server that connects to both a XMPP server and a non-XMPP server. By running a transport, I can use my Jabber client to talk to someone using, say, MSN Messenger. A transport typically connects once to the remote network for each JID that it sees as online. That is, it's your option 2 in reverse. This is because there is no special relationship between the transport and the non-XMPP network; the transport is simply acting as a bunch of regular clients. For this to work, XMPP clients must first register with the transport, giving login credentials for the remote network, and allowing the transport to view their presence. The only reason this has a chance of scaling better is that there can be many transports for the same remote network. For example, my Jabber server could run a transport to MSN, another Jabber server could run another one, and so on, each one providing connections for a different subset of XMPP users. While this spreads out the load on the Jabber side, and load balancing on your system may spread out the load as well, it still requires many connections between the two systems. In your case, because (I assume) the non-XMPP side of things is cooperating, putting a XMPP server interface on the non-XMPP server is likely your best bet. That server interface is best suited for managing the mapping between XMPP JIDs and how that JID will appear on its own network, rather than forcing XMPP users to register and so on. In case you haven't seen these, you might find them useful: http://www.jabber.org/jabber-for-geeks/technology-overview http://www.xmpp.org/protocols/ http://www.xmpp.org/extensions/ Hope that helps. | [
"networking",
"architecture",
"xmpp"
] | 9 | 4 | 4,369 | 5 | 0 | 2008-08-30T04:11:35.070000 | 2008-08-30T17:59:05.407000 |
35,699 | 1,842,279 | On a two-column page, how can I grow the left div to the same height of the right div using CSS or Javascript? | I'm trying to make a two-column page using a div-based layout (no tables please!). Problem is, I can't grow the left div to match the height of the right one. My right div typically has a lot of content. Here's a paired down example of my template to illustrate the problem. nav1 nav2 nav3 nav4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.... | Use jQuery for this problem; just call this function in your ready function: function setHeight(){ var height = $(document).height(); //optionally, subtract some from the height $("#leftDiv").css("height", height + "px"); } | On a two-column page, how can I grow the left div to the same height of the right div using CSS or Javascript? I'm trying to make a two-column page using a div-based layout (no tables please!). Problem is, I can't grow the left div to match the height of the right one. My right div typically has a lot of content. Here's a paired down example of my template to illustrate the problem. nav1 nav2 nav3 nav4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.... | TITLE:
On a two-column page, how can I grow the left div to the same height of the right div using CSS or Javascript?
QUESTION:
I'm trying to make a two-column page using a div-based layout (no tables please!). Problem is, I can't grow the left div to match the height of the right one. My right div typically has a lot of content. Here's a paired down example of my template to illustrate the problem. nav1 nav2 nav3 nav4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna....
ANSWER:
Use jQuery for this problem; just call this function in your ready function: function setHeight(){ var height = $(document).height(); //optionally, subtract some from the height $("#leftDiv").css("height", height + "px"); } | [
"javascript",
"html",
"css"
] | 16 | 3 | 6,525 | 11 | 0 | 2008-08-30T05:28:40.483000 | 2009-12-03T19:24:24.997000 |
35,700 | 35,715 | Writing cross-platform apps in C | What things should be kept most in mind when writing cross-platform applications in C? Targeted platforms: 32-bit Intel based PC, Mac, and Linux. I'm especially looking for the type of versatility that Jungle Disk has in their USB desktop edition ( http://www.jungledisk.com/desktop/download.aspx ) What are tips and "gotchas" for this type of development? | I maintained for a number of years an ANSI C networking library that was ported to close to 30 different OS's and compilers. The library didn't have any GUI components, which made it easier. We ended up abstracting out into dedicated source files any routine that was not consistent across platforms, and used #defines where appropriate in those source files. This kept the code that was adjusted per platform isolated away from the main business logic of the library. We also made extensive use of typedefs and our own dedicated types so that we could easily change them per platform if needed. This made the port to 64-bit platforms fairly easy. If you are looking to have GUI components, I would suggest looking at GUI toolkits such as WxWindows or Qt (which are both C++ libraries). | Writing cross-platform apps in C What things should be kept most in mind when writing cross-platform applications in C? Targeted platforms: 32-bit Intel based PC, Mac, and Linux. I'm especially looking for the type of versatility that Jungle Disk has in their USB desktop edition ( http://www.jungledisk.com/desktop/download.aspx ) What are tips and "gotchas" for this type of development? | TITLE:
Writing cross-platform apps in C
QUESTION:
What things should be kept most in mind when writing cross-platform applications in C? Targeted platforms: 32-bit Intel based PC, Mac, and Linux. I'm especially looking for the type of versatility that Jungle Disk has in their USB desktop edition ( http://www.jungledisk.com/desktop/download.aspx ) What are tips and "gotchas" for this type of development?
ANSWER:
I maintained for a number of years an ANSI C networking library that was ported to close to 30 different OS's and compilers. The library didn't have any GUI components, which made it easier. We ended up abstracting out into dedicated source files any routine that was not consistent across platforms, and used #defines where appropriate in those source files. This kept the code that was adjusted per platform isolated away from the main business logic of the library. We also made extensive use of typedefs and our own dedicated types so that we could easily change them per platform if needed. This made the port to 64-bit platforms fairly easy. If you are looking to have GUI components, I would suggest looking at GUI toolkits such as WxWindows or Qt (which are both C++ libraries). | [
"c",
"cross-platform",
"32-bit"
] | 14 | 10 | 8,437 | 8 | 0 | 2008-08-30T05:30:24.333000 | 2008-08-30T05:48:56.537000 |
35,707 | 35,710 | Decision making in distributed applications | With a distributed application, where you have lots of clients and one main server, should you: Make the clients dumb and the server smart: clients are fast and non-invasive. Business rules are needed in only 1 place Make the clients smart and the server dumb: take as much load as possible off of the server Additional info: Clients collect tons of data about the computer they are on. The server must analyze all of this info to determine the health of these computers The owners of the client computers are temperamental and will shut down the clients if the client starts to consume too many resources (thus negating the purpose of the distributed app in helping diagnose problems) | You should do as much client-side processing as possible. This will enable your application to scale better than doing processing server-side. To solve your temperamental user problem, you could look into making your client processes run at a very low priority so there's no noticeable decrease in performance on the part of the user. | Decision making in distributed applications With a distributed application, where you have lots of clients and one main server, should you: Make the clients dumb and the server smart: clients are fast and non-invasive. Business rules are needed in only 1 place Make the clients smart and the server dumb: take as much load as possible off of the server Additional info: Clients collect tons of data about the computer they are on. The server must analyze all of this info to determine the health of these computers The owners of the client computers are temperamental and will shut down the clients if the client starts to consume too many resources (thus negating the purpose of the distributed app in helping diagnose problems) | TITLE:
Decision making in distributed applications
QUESTION:
With a distributed application, where you have lots of clients and one main server, should you: Make the clients dumb and the server smart: clients are fast and non-invasive. Business rules are needed in only 1 place Make the clients smart and the server dumb: take as much load as possible off of the server Additional info: Clients collect tons of data about the computer they are on. The server must analyze all of this info to determine the health of these computers The owners of the client computers are temperamental and will shut down the clients if the client starts to consume too many resources (thus negating the purpose of the distributed app in helping diagnose problems)
ANSWER:
You should do as much client-side processing as possible. This will enable your application to scale better than doing processing server-side. To solve your temperamental user problem, you could look into making your client processes run at a very low priority so there's no noticeable decrease in performance on the part of the user. | [
"distributed"
] | 2 | 3 | 798 | 3 | 0 | 2008-08-30T05:41:38.677000 | 2008-08-30T05:44:31.273000 |
35,709 | 35,735 | How do I change my Active Sound Card on the Fly? | I currently have speakers set up both in my office and in my living room, connected to my PC via two sound cards, and would like to switch the set of speakers I'm outputting to on the fly. Anyone know an application or a windows API call that I can use to change the default sound output device? It is currently a bit of a pain to traverse the existing control panel system. | That topic is covered in depth here Easily Change or Switch the Default Audio Sound Output in Vista or XP. Note that sound management was changed in Vista significantly. On a side note, I believe SnapStream is/was working on an application to allo multi-channel sound cards to output to different rooms (sets of speakers) simultaneously. | How do I change my Active Sound Card on the Fly? I currently have speakers set up both in my office and in my living room, connected to my PC via two sound cards, and would like to switch the set of speakers I'm outputting to on the fly. Anyone know an application or a windows API call that I can use to change the default sound output device? It is currently a bit of a pain to traverse the existing control panel system. | TITLE:
How do I change my Active Sound Card on the Fly?
QUESTION:
I currently have speakers set up both in my office and in my living room, connected to my PC via two sound cards, and would like to switch the set of speakers I'm outputting to on the fly. Anyone know an application or a windows API call that I can use to change the default sound output device? It is currently a bit of a pain to traverse the existing control panel system.
ANSWER:
That topic is covered in depth here Easily Change or Switch the Default Audio Sound Output in Vista or XP. Note that sound management was changed in Vista significantly. On a side note, I believe SnapStream is/was working on an application to allo multi-channel sound cards to output to different rooms (sets of speakers) simultaneously. | [
"windows",
"audio",
"hardware"
] | 5 | 7 | 1,961 | 1 | 0 | 2008-08-30T05:43:56.830000 | 2008-08-30T06:21:06.537000 |
35,721 | 35,723 | Seeking code highlighter recommendation for WordPress | Can anybody recommend a reliable and decently documented code highlighter for WordPress 2.6.1? I have tried Code Snippet by Roman Roan and Developer Formatter by Gilberto Saraiva. But they don't seem to work as described in the documentation and are mangling the code snippets instead of prettifying them. | I use WP-Syntax and it's worked very well for me. It's supported every language I've thrown at it so far, and the colors can be customized for a particular theme (though the defaults look just fine too) | Seeking code highlighter recommendation for WordPress Can anybody recommend a reliable and decently documented code highlighter for WordPress 2.6.1? I have tried Code Snippet by Roman Roan and Developer Formatter by Gilberto Saraiva. But they don't seem to work as described in the documentation and are mangling the code snippets instead of prettifying them. | TITLE:
Seeking code highlighter recommendation for WordPress
QUESTION:
Can anybody recommend a reliable and decently documented code highlighter for WordPress 2.6.1? I have tried Code Snippet by Roman Roan and Developer Formatter by Gilberto Saraiva. But they don't seem to work as described in the documentation and are mangling the code snippets instead of prettifying them.
ANSWER:
I use WP-Syntax and it's worked very well for me. It's supported every language I've thrown at it so far, and the colors can be customized for a particular theme (though the defaults look just fine too) | [
"php",
"wordpress",
"codehighlighter",
"geshi"
] | 10 | 6 | 529 | 5 | 0 | 2008-08-30T05:57:20.167000 | 2008-08-30T05:58:33.173000 |
35,745 | 35,756 | Are there any tools to visualize template/class methods and their usage? | I have taken over a large code base and would like to get an overview how and where certain classes and their methods are used. Is there any good tool that can somehow visualize the dependencies and draw a nice call tree or something similar? The code is in C++ in Visual Studio if that helps narrow down any selection. | Here are a few options: CodeDrawer CC-RIDER Doxygen The last one, doxygen, is more of an automatic documentation tool, but it is capable of generating dependency graphs and inheritance diagrams. It's also licensed under the GPL, unlike the first two which are not free. | Are there any tools to visualize template/class methods and their usage? I have taken over a large code base and would like to get an overview how and where certain classes and their methods are used. Is there any good tool that can somehow visualize the dependencies and draw a nice call tree or something similar? The code is in C++ in Visual Studio if that helps narrow down any selection. | TITLE:
Are there any tools to visualize template/class methods and their usage?
QUESTION:
I have taken over a large code base and would like to get an overview how and where certain classes and their methods are used. Is there any good tool that can somehow visualize the dependencies and draw a nice call tree or something similar? The code is in C++ in Visual Studio if that helps narrow down any selection.
ANSWER:
Here are a few options: CodeDrawer CC-RIDER Doxygen The last one, doxygen, is more of an automatic documentation tool, but it is capable of generating dependency graphs and inheritance diagrams. It's also licensed under the GPL, unlike the first two which are not free. | [
"visualization"
] | 3 | 1 | 791 | 5 | 0 | 2008-08-30T06:51:07.103000 | 2008-08-30T07:17:17.697000 |
35,748 | 35,908 | Is it possible to list named events in Windows? | I would like to create events for certain resources that are used across various processes and access these events by name. The problem seems to be that the names of the events must be known to all applications referring to them. Is there maybe a way to get a list of names events in the system? I am aware that I might use some standard names, but it seems rather inflexible with regard to future extensibility (all application would require a recompile). I'm afraid, I can't even consider ZwOpenDirectoryObject, because it is described as needing Windows XP or higher, so it is out of question. Thanks for the suggestion though. I am a little unsure about shared memory, because I haven't tried it so far. Might do some reading in that area I guess. Configuration files and registry are a slight problem, because they do tend to fail with Vista due to access problems. I am a bit afraid, that shared memory will have the same problem. The idea with ProcessExplorer sounds promising. Does anyone know an API that could be used for listing events for a process? And, does it work without administrative rights? Thank you for the clarification. There is not really a master process. It is more of a driver dll that is used from different processes and the events would be used to "lock" resources used by these processes. I am thinking about setting up a central service that has sufficient access rights even under Vista. It will certainly complicate things, but it might be the only thing left facing the problems with security. | Do not mix up the user mode ZwOpenDirectoryObject with the kernel mode ZwOpenDirectoryObject -- the kernel mode API ( http://msdn.microsoft.com/en-us/library/ms800966.aspx ) indeed seems to available as of XP only, but the user mode version should be available at least since NT 4. Anyway, I would not recommend using ZwOpenDirectoryObject. Why should configuration files and registry keys fail on Vista? Of course, you have to get the security settings right -- but you would have to do that for your named events as well -- so there should not be a big difference here. Maybe you should tell us some more details about the nature of your processes -- do they all run within the same logon session or do they run as different users even? And is there some master process or who creates the events in the first place? Frankly, I tend to find the Process Explorer idea to be not a very good one. Despite the fact that you probably will not be able to accomplish that without using undocumented APIs and/or a device driver, I do not think that a process should be spelunking around in the handle table of another process just to find out the names of some kernel objects. And, of course, the same security issues apply again. | Is it possible to list named events in Windows? I would like to create events for certain resources that are used across various processes and access these events by name. The problem seems to be that the names of the events must be known to all applications referring to them. Is there maybe a way to get a list of names events in the system? I am aware that I might use some standard names, but it seems rather inflexible with regard to future extensibility (all application would require a recompile). I'm afraid, I can't even consider ZwOpenDirectoryObject, because it is described as needing Windows XP or higher, so it is out of question. Thanks for the suggestion though. I am a little unsure about shared memory, because I haven't tried it so far. Might do some reading in that area I guess. Configuration files and registry are a slight problem, because they do tend to fail with Vista due to access problems. I am a bit afraid, that shared memory will have the same problem. The idea with ProcessExplorer sounds promising. Does anyone know an API that could be used for listing events for a process? And, does it work without administrative rights? Thank you for the clarification. There is not really a master process. It is more of a driver dll that is used from different processes and the events would be used to "lock" resources used by these processes. I am thinking about setting up a central service that has sufficient access rights even under Vista. It will certainly complicate things, but it might be the only thing left facing the problems with security. | TITLE:
Is it possible to list named events in Windows?
QUESTION:
I would like to create events for certain resources that are used across various processes and access these events by name. The problem seems to be that the names of the events must be known to all applications referring to them. Is there maybe a way to get a list of names events in the system? I am aware that I might use some standard names, but it seems rather inflexible with regard to future extensibility (all application would require a recompile). I'm afraid, I can't even consider ZwOpenDirectoryObject, because it is described as needing Windows XP or higher, so it is out of question. Thanks for the suggestion though. I am a little unsure about shared memory, because I haven't tried it so far. Might do some reading in that area I guess. Configuration files and registry are a slight problem, because they do tend to fail with Vista due to access problems. I am a bit afraid, that shared memory will have the same problem. The idea with ProcessExplorer sounds promising. Does anyone know an API that could be used for listing events for a process? And, does it work without administrative rights? Thank you for the clarification. There is not really a master process. It is more of a driver dll that is used from different processes and the events would be used to "lock" resources used by these processes. I am thinking about setting up a central service that has sufficient access rights even under Vista. It will certainly complicate things, but it might be the only thing left facing the problems with security.
ANSWER:
Do not mix up the user mode ZwOpenDirectoryObject with the kernel mode ZwOpenDirectoryObject -- the kernel mode API ( http://msdn.microsoft.com/en-us/library/ms800966.aspx ) indeed seems to available as of XP only, but the user mode version should be available at least since NT 4. Anyway, I would not recommend using ZwOpenDirectoryObject. Why should configuration files and registry keys fail on Vista? Of course, you have to get the security settings right -- but you would have to do that for your named events as well -- so there should not be a big difference here. Maybe you should tell us some more details about the nature of your processes -- do they all run within the same logon session or do they run as different users even? And is there some master process or who creates the events in the first place? Frankly, I tend to find the Process Explorer idea to be not a very good one. Despite the fact that you probably will not be able to accomplish that without using undocumented APIs and/or a device driver, I do not think that a process should be spelunking around in the handle table of another process just to find out the names of some kernel objects. And, of course, the same security issues apply again. | [
"windows",
"events"
] | 1 | 1 | 4,260 | 3 | 0 | 2008-08-30T06:56:31.507000 | 2008-08-30T11:58:22.887000 |
35,753 | 259,591 | Is Python good for big software projects (not web based)? | Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)? What IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion. | We've used IronPython to build our flagship spreadsheet application (40kloc production code - and it's Python, which IMO means loc per feature is low) at Resolver Systems, so I'd definitely say it's ready for production use of complex apps. There are two ways in which this might not be a useful answer to you:-) We're using IronPython, not the more usual CPython. This gives us the huge advantage of being able to use.NET class libraries. I may be setting myself up for flaming here, but I would say that I've never really seen a CPython application that looked "professional" - so having access to the WinForms widget set was a huge win for us. IronPython also gives us the advantage of being able to easily drop into C# if we need a performance boost. (Though to be honest we have never needed to do that. All of our performance problems to date have been because we chose dumb algorithms rather than because the language was slow.) Using C# from IP is much easier than writing a C Extension for CPython. We're an Extreme Programming shop, so we write tests before we write code. I would not write production code in a dynamic language without writing the tests first; the lack of a compile step needs to be covered by something, and as other people have pointed out, refactoring without it can be tough. (Greg Hewgill's answer suggests he's had the same problem. On the other hand, I don't think I would write - or especially refactor - production code in any language these days without writing the tests first - but YMMV.) Re: the IDE - we've been pretty much fine with each person using their favourite text editor; if you prefer something a bit more heavyweight then WingIDE is pretty well-regarded. | Is Python good for big software projects (not web based)? Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)? What IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion. | TITLE:
Is Python good for big software projects (not web based)?
QUESTION:
Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). Except for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)? What IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.
ANSWER:
We've used IronPython to build our flagship spreadsheet application (40kloc production code - and it's Python, which IMO means loc per feature is low) at Resolver Systems, so I'd definitely say it's ready for production use of complex apps. There are two ways in which this might not be a useful answer to you:-) We're using IronPython, not the more usual CPython. This gives us the huge advantage of being able to use.NET class libraries. I may be setting myself up for flaming here, but I would say that I've never really seen a CPython application that looked "professional" - so having access to the WinForms widget set was a huge win for us. IronPython also gives us the advantage of being able to easily drop into C# if we need a performance boost. (Though to be honest we have never needed to do that. All of our performance problems to date have been because we chose dumb algorithms rather than because the language was slow.) Using C# from IP is much easier than writing a C Extension for CPython. We're an Extreme Programming shop, so we write tests before we write code. I would not write production code in a dynamic language without writing the tests first; the lack of a compile step needs to be covered by something, and as other people have pointed out, refactoring without it can be tough. (Greg Hewgill's answer suggests he's had the same problem. On the other hand, I don't think I would write - or especially refactor - production code in any language these days without writing the tests first - but YMMV.) Re: the IDE - we've been pretty much fine with each person using their favourite text editor; if you prefer something a bit more heavyweight then WingIDE is pretty well-regarded. | [
"python",
"ide"
] | 29 | 34 | 30,003 | 13 | 0 | 2008-08-30T07:08:22.587000 | 2008-11-03T19:05:14.623000 |
35,762 | 35,770 | Linux GUI development | I have a large GUI project that I'd like to port to Linux. What is the most recommended framework to utilize for GUI programming in Linux? Are Frameworks such as KDE / Gnome usable for this objective Or is better to use something more generic other than X? I feel like if I chose one of Gnome or KDE, I'm closing the market out for a chunk of the Linux market who have chosen one over the other. (Yes I know there is overlap) Is there a better way? Or would I have to create 2 complete GUI apps to have near 100% coverage? It's not necessary to have a cross-platform solution that will also work on Win32. | Your best bet may be to port it to a cross-platform widget library such as wxWidgets, which would give you portability to any platform wxWidgets supports. It's also important to make the distinction between Gnome libraries and GTK, and likewise KDE libraries and Qt. If you write the code to use GTK or Qt, it should work fine for users of any desktop environment, including less popular ones like XFCE. If you use other Gnome or KDE-specific libraries to do non-widget-related tasks, your app would be less portable between desktop environments. | Linux GUI development I have a large GUI project that I'd like to port to Linux. What is the most recommended framework to utilize for GUI programming in Linux? Are Frameworks such as KDE / Gnome usable for this objective Or is better to use something more generic other than X? I feel like if I chose one of Gnome or KDE, I'm closing the market out for a chunk of the Linux market who have chosen one over the other. (Yes I know there is overlap) Is there a better way? Or would I have to create 2 complete GUI apps to have near 100% coverage? It's not necessary to have a cross-platform solution that will also work on Win32. | TITLE:
Linux GUI development
QUESTION:
I have a large GUI project that I'd like to port to Linux. What is the most recommended framework to utilize for GUI programming in Linux? Are Frameworks such as KDE / Gnome usable for this objective Or is better to use something more generic other than X? I feel like if I chose one of Gnome or KDE, I'm closing the market out for a chunk of the Linux market who have chosen one over the other. (Yes I know there is overlap) Is there a better way? Or would I have to create 2 complete GUI apps to have near 100% coverage? It's not necessary to have a cross-platform solution that will also work on Win32.
ANSWER:
Your best bet may be to port it to a cross-platform widget library such as wxWidgets, which would give you portability to any platform wxWidgets supports. It's also important to make the distinction between Gnome libraries and GTK, and likewise KDE libraries and Qt. If you write the code to use GTK or Qt, it should work fine for users of any desktop environment, including less popular ones like XFCE. If you use other Gnome or KDE-specific libraries to do non-widget-related tasks, your app would be less portable between desktop environments. | [
"c++",
"linux",
"user-interface",
"gnome",
"kde-plasma"
] | 15 | 15 | 8,745 | 4 | 0 | 2008-08-30T07:51:26.977000 | 2008-08-30T08:12:06.957000 |
35,772 | 40,188 | How to embed user-specific data in .NET windows setup app at setup download time? | I'd like to have a link in my ASP.NET web site that authenticated users click to download a windows app that is already pre-configured with their client ID and some site config data. My goal is no typing required for the user during the client app install, both for the user friendliness, and to avoid config errors from mis-typed technical bits. Ideally I'd like the web server-side code to run as part of the ASP.NET app. FogBugz seems to do something like this. There is a menu option within the web app to download a screenshot tool, and when you download and run the installer, it knows your particular FogBugz web address so it can send screenshots there. (Hey Joel, looking for a question to answer? hint—hint ) | The way the FogBugz screenshot setup tool does this is that it appends a 256 byte block at the end of the setup program at the moment it is downloaded. In other words, the download script spits out all the bytes from setup.exe and then an extra 256 with the url for the FogBugz server, plus any padding. Windows ignores these extra bytes when the.exe is run (provided you turned off the CRC check for your setup installer - we're using InnoSetup ). After installation, we run the Screenshot program with a command line switch that tells it where the setup installer is. It looks at the end of the setup.exe and finds it's info, and then writes that to the registry so the user doesn't have to know it. | How to embed user-specific data in .NET windows setup app at setup download time? I'd like to have a link in my ASP.NET web site that authenticated users click to download a windows app that is already pre-configured with their client ID and some site config data. My goal is no typing required for the user during the client app install, both for the user friendliness, and to avoid config errors from mis-typed technical bits. Ideally I'd like the web server-side code to run as part of the ASP.NET app. FogBugz seems to do something like this. There is a menu option within the web app to download a screenshot tool, and when you download and run the installer, it knows your particular FogBugz web address so it can send screenshots there. (Hey Joel, looking for a question to answer? hint—hint ) | TITLE:
How to embed user-specific data in .NET windows setup app at setup download time?
QUESTION:
I'd like to have a link in my ASP.NET web site that authenticated users click to download a windows app that is already pre-configured with their client ID and some site config data. My goal is no typing required for the user during the client app install, both for the user friendliness, and to avoid config errors from mis-typed technical bits. Ideally I'd like the web server-side code to run as part of the ASP.NET app. FogBugz seems to do something like this. There is a menu option within the web app to download a screenshot tool, and when you download and run the installer, it knows your particular FogBugz web address so it can send screenshots there. (Hey Joel, looking for a question to answer? hint—hint )
ANSWER:
The way the FogBugz screenshot setup tool does this is that it appends a 256 byte block at the end of the setup program at the moment it is downloaded. In other words, the download script spits out all the bytes from setup.exe and then an extra 256 with the url for the FogBugz server, plus any padding. Windows ignores these extra bytes when the.exe is run (provided you turned off the CRC check for your setup installer - we're using InnoSetup ). After installation, we run the Screenshot program with a command line switch that tells it where the setup installer is. It looks at the end of the setup.exe and finds it's info, and then writes that to the registry so the user doesn't have to know it. | [
".net",
"windows",
"installation",
"fogbugz"
] | 2 | 2 | 237 | 3 | 0 | 2008-08-30T08:16:37.553000 | 2008-09-02T18:12:57.987000 |
35,782 | 35,784 | Formatting tabular data using unicode characters | I need to produce a calculation trace file containing tabular data showing intermediate results. I am currently using a combination of the standard ascii pipe symbols (|) and dashes (-) to draw the table lines: E.g. Numerator | Denominator | Result ----------|-------------|------- 6 | 2 | 3 10 | 5 | 2 Are there any unicode characters that could be used to produce a more professional looking table? (The file must be a raw text format and cannot use HTML or any other markup) Edit: I've added an example of what the table now looks like having taken the suggestion on board and used the unicode box drawing characters: Numerator │ Denominator │ Result ──────────┼─────────────┼─────── 6 │ 2 │ 3 10 │ 5 │ 2 | There are Unicode box drawing characters (look for Box Drawing under Geometrical Symbols - the chart itself is a PDF). I don't have any idea how widely supported those characters are, though. | Formatting tabular data using unicode characters I need to produce a calculation trace file containing tabular data showing intermediate results. I am currently using a combination of the standard ascii pipe symbols (|) and dashes (-) to draw the table lines: E.g. Numerator | Denominator | Result ----------|-------------|------- 6 | 2 | 3 10 | 5 | 2 Are there any unicode characters that could be used to produce a more professional looking table? (The file must be a raw text format and cannot use HTML or any other markup) Edit: I've added an example of what the table now looks like having taken the suggestion on board and used the unicode box drawing characters: Numerator │ Denominator │ Result ──────────┼─────────────┼─────── 6 │ 2 │ 3 10 │ 5 │ 2 | TITLE:
Formatting tabular data using unicode characters
QUESTION:
I need to produce a calculation trace file containing tabular data showing intermediate results. I am currently using a combination of the standard ascii pipe symbols (|) and dashes (-) to draw the table lines: E.g. Numerator | Denominator | Result ----------|-------------|------- 6 | 2 | 3 10 | 5 | 2 Are there any unicode characters that could be used to produce a more professional looking table? (The file must be a raw text format and cannot use HTML or any other markup) Edit: I've added an example of what the table now looks like having taken the suggestion on board and used the unicode box drawing characters: Numerator │ Denominator │ Result ──────────┼─────────────┼─────── 6 │ 2 │ 3 10 │ 5 │ 2
ANSWER:
There are Unicode box drawing characters (look for Box Drawing under Geometrical Symbols - the chart itself is a PDF). I don't have any idea how widely supported those characters are, though. | [
"unicode",
"format",
"special-characters",
"non-ascii-characters"
] | 3 | 3 | 2,054 | 3 | 0 | 2008-08-30T08:26:43.630000 | 2008-08-30T08:31:22.933000 |
35,785 | 35,821 | XML serialization in Java? | What is the Java analogue of.NET's XML serialization? | 2008 Answer The "Official" Java API for this is now JAXB - Java API for XML Binding. See Tutorial by Oracle. The reference implementation lives at http://jaxb.java.net/ 2018 Update Note that the Java EE and CORBA Modules are deprecated in SE in JDK9 and to be removed from SE in JDK11. Therefore, to use JAXB it will either need to be in your existing enterprise class environment bundled by your e.g. app server, or you will need to bring it in manually. | XML serialization in Java? What is the Java analogue of.NET's XML serialization? | TITLE:
XML serialization in Java?
QUESTION:
What is the Java analogue of.NET's XML serialization?
ANSWER:
2008 Answer The "Official" Java API for this is now JAXB - Java API for XML Binding. See Tutorial by Oracle. The reference implementation lives at http://jaxb.java.net/ 2018 Update Note that the Java EE and CORBA Modules are deprecated in SE in JDK9 and to be removed from SE in JDK11. Therefore, to use JAXB it will either need to be in your existing enterprise class environment bundled by your e.g. app server, or you will need to bring it in manually. | [
"java",
"xml",
"serialization"
] | 108 | 84 | 149,222 | 11 | 0 | 2008-08-30T08:33:01.133000 | 2008-08-30T09:31:57.530000 |
35,798 | 35,803 | Techniques to detect Polymorphic and Metamorphic viruses? | What techniques can be applied to detect Polymorphic and Metamorphic viruses? How difficult is to implement these techniques? Are these techniques being applied in modern day anti-virus softwares? | I thought most of the virus scanners nowadays use sandbox techniques to check for "bad" behavior. Therefore the polymorphic virusses will also be detected. of course these detection techniques are also known to virus creators, and can easily be bypassed using a bunch of random, unharmfull, code executions before the actual payload. | Techniques to detect Polymorphic and Metamorphic viruses? What techniques can be applied to detect Polymorphic and Metamorphic viruses? How difficult is to implement these techniques? Are these techniques being applied in modern day anti-virus softwares? | TITLE:
Techniques to detect Polymorphic and Metamorphic viruses?
QUESTION:
What techniques can be applied to detect Polymorphic and Metamorphic viruses? How difficult is to implement these techniques? Are these techniques being applied in modern day anti-virus softwares?
ANSWER:
I thought most of the virus scanners nowadays use sandbox techniques to check for "bad" behavior. Therefore the polymorphic virusses will also be detected. of course these detection techniques are also known to virus creators, and can easily be bypassed using a bunch of random, unharmfull, code executions before the actual payload. | [
"antivirus",
"virus"
] | 3 | 2 | 1,984 | 2 | 0 | 2008-08-30T08:55:43.543000 | 2008-08-30T09:11:31.713000 |
35,805 | 35,823 | Why is my instance variable not in __dict__? | If I create a class A as follows: class A: def __init__(self): self.name = 'A' Inspecting the __dict__ member looks like {'name': 'A'} If however I create a class B: class B: name = 'B' __dict__ is empty. What is the difference between the two, and why doesn't name show up in B 's __dict__? | B.name is a class attribute, not an instance attribute. It shows up in B.__dict__, but not in b = B(); b.__dict__. The distinction is obscured somewhat because when you access an attribute on an instance, the class dict is a fallback. So in the above example, b.name will give you the value of B.name. | Why is my instance variable not in __dict__? If I create a class A as follows: class A: def __init__(self): self.name = 'A' Inspecting the __dict__ member looks like {'name': 'A'} If however I create a class B: class B: name = 'B' __dict__ is empty. What is the difference between the two, and why doesn't name show up in B 's __dict__? | TITLE:
Why is my instance variable not in __dict__?
QUESTION:
If I create a class A as follows: class A: def __init__(self): self.name = 'A' Inspecting the __dict__ member looks like {'name': 'A'} If however I create a class B: class B: name = 'B' __dict__ is empty. What is the difference between the two, and why doesn't name show up in B 's __dict__?
ANSWER:
B.name is a class attribute, not an instance attribute. It shows up in B.__dict__, but not in b = B(); b.__dict__. The distinction is obscured somewhat because when you access an attribute on an instance, the class dict is a fallback. So in the above example, b.name will give you the value of B.name. | [
"python"
] | 39 | 47 | 5,928 | 2 | 0 | 2008-08-30T09:12:41.367000 | 2008-08-30T09:33:00.990000 |
35,817 | 35,857 | How to escape os.system() calls? | When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing the following, but am sure there must be a library function for this, or at least a more elegant/robust/efficient option: def sh_escape(s): return s.replace("(","\\(").replace(")","\\)").replace(" ","\\ ")
os.system("cat %s | grep something | sort > %s" % (sh_escape(in_filename), sh_escape(out_filename))) Edit: I've accepted the simple answer of using quotes, don't know why I didn't think of that; I guess because I came from Windows where ' and " behave a little differently. Regarding security, I understand the concern, but, in this case, I'm interested in a quick and easy solution which os.system() provides, and the source of the strings is either not user-generated or at least entered by a trusted user (me). | This is what I use: def shellquote(s): return "'" + s.replace("'", "'\\''") + "'" The shell will always accept a quoted filename and remove the surrounding quotes before passing it to the program in question. Notably, this avoids problems with filenames that contain spaces or any other kind of nasty shell metacharacter. Update: If you are using Python 3.3 or later, use shlex.quote instead of rolling your own. | How to escape os.system() calls? When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing the following, but am sure there must be a library function for this, or at least a more elegant/robust/efficient option: def sh_escape(s): return s.replace("(","\\(").replace(")","\\)").replace(" ","\\ ")
os.system("cat %s | grep something | sort > %s" % (sh_escape(in_filename), sh_escape(out_filename))) Edit: I've accepted the simple answer of using quotes, don't know why I didn't think of that; I guess because I came from Windows where ' and " behave a little differently. Regarding security, I understand the concern, but, in this case, I'm interested in a quick and easy solution which os.system() provides, and the source of the strings is either not user-generated or at least entered by a trusted user (me). | TITLE:
How to escape os.system() calls?
QUESTION:
When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash. I'm currently doing the following, but am sure there must be a library function for this, or at least a more elegant/robust/efficient option: def sh_escape(s): return s.replace("(","\\(").replace(")","\\)").replace(" ","\\ ")
os.system("cat %s | grep something | sort > %s" % (sh_escape(in_filename), sh_escape(out_filename))) Edit: I've accepted the simple answer of using quotes, don't know why I didn't think of that; I guess because I came from Windows where ' and " behave a little differently. Regarding security, I understand the concern, but, in this case, I'm interested in a quick and easy solution which os.system() provides, and the source of the strings is either not user-generated or at least entered by a trusted user (me).
ANSWER:
This is what I use: def shellquote(s): return "'" + s.replace("'", "'\\''") + "'" The shell will always accept a quoted filename and remove the surrounding quotes before passing it to the program in question. Notably, this avoids problems with filenames that contain spaces or any other kind of nasty shell metacharacter. Update: If you are using Python 3.3 or later, use shlex.quote instead of rolling your own. | [
"python",
"shell",
"escaping"
] | 145 | 90 | 119,456 | 10 | 0 | 2008-08-30T09:27:24.640000 | 2008-08-30T10:13:11.503000 |
35,837 | 35,845 | What is the Difference Between Mercurial and Git? | I've been using git for some time now on Windows (with msysGit) and I like the idea of distributed source control. Just recently I've been looking at Mercurial (hg) and it looks interesting. However, I can't wrap my head around the differences between hg and git. Has anyone made a side-by-side comparison between git and hg? I'm interested to know what differs hg and git without having to jump into a fanboy discussion. | These articles may help: Git vs. Mercurial: Please Relax (Git is MacGyver and Mercurial is James Bond) The Differences Between Mercurial and Git Edit: Comparing Git and Mercurial to celebrities seems to be a trend. Here's one more: Git is Wesley Snipes, Mercurial is Denzel Washington | What is the Difference Between Mercurial and Git? I've been using git for some time now on Windows (with msysGit) and I like the idea of distributed source control. Just recently I've been looking at Mercurial (hg) and it looks interesting. However, I can't wrap my head around the differences between hg and git. Has anyone made a side-by-side comparison between git and hg? I'm interested to know what differs hg and git without having to jump into a fanboy discussion. | TITLE:
What is the Difference Between Mercurial and Git?
QUESTION:
I've been using git for some time now on Windows (with msysGit) and I like the idea of distributed source control. Just recently I've been looking at Mercurial (hg) and it looks interesting. However, I can't wrap my head around the differences between hg and git. Has anyone made a side-by-side comparison between git and hg? I'm interested to know what differs hg and git without having to jump into a fanboy discussion.
ANSWER:
These articles may help: Git vs. Mercurial: Please Relax (Git is MacGyver and Mercurial is James Bond) The Differences Between Mercurial and Git Edit: Comparing Git and Mercurial to celebrities seems to be a trend. Here's one more: Git is Wesley Snipes, Mercurial is Denzel Washington | [
"git",
"version-control",
"mercurial",
"comparison",
"dvcs"
] | 726 | 345 | 655,544 | 25 | 0 | 2008-08-30T09:48:27.520000 | 2008-08-30T09:57:01.963000 |
35,842 | 35,885 | How can a Java program get its own process ID? | How do I get the id of my Java process? I know there are several platform-dependent hacks, but I would prefer a more generic solution. | There exists no platform-independent way that can be guaranteed to work in all jvm implementations. ManagementFactory.getRuntimeMXBean().getName() looks like the best (closest) solution, and typically includes the PID. It's short, and probably works in every implementation in wide use. On linux+windows it returns a value like "12345@hostname" ( 12345 being the process id). Beware though that according to the docs, there are no guarantees about this value: Returns the name representing the running Java virtual machine. The returned name string can be any arbitrary string and a Java virtual machine implementation can choose to embed platform-specific useful information in the returned name string. Each running virtual machine could have a different name. In Java 9 the new process API can be used: long pid = ProcessHandle.current().pid(); | How can a Java program get its own process ID? How do I get the id of my Java process? I know there are several platform-dependent hacks, but I would prefer a more generic solution. | TITLE:
How can a Java program get its own process ID?
QUESTION:
How do I get the id of my Java process? I know there are several platform-dependent hacks, but I would prefer a more generic solution.
ANSWER:
There exists no platform-independent way that can be guaranteed to work in all jvm implementations. ManagementFactory.getRuntimeMXBean().getName() looks like the best (closest) solution, and typically includes the PID. It's short, and probably works in every implementation in wide use. On linux+windows it returns a value like "12345@hostname" ( 12345 being the process id). Beware though that according to the docs, there are no guarantees about this value: Returns the name representing the running Java virtual machine. The returned name string can be any arbitrary string and a Java virtual machine implementation can choose to embed platform-specific useful information in the returned name string. Each running virtual machine could have a different name. In Java 9 the new process API can be used: long pid = ProcessHandle.current().pid(); | [
"java",
"pid"
] | 427 | 422 | 359,347 | 22 | 0 | 2008-08-30T09:53:25.420000 | 2008-08-30T11:11:17.277000 |
35,849 | 35,892 | What logging is good logging for your app? | So we've discussed logging in passing at my place of work and I was wondering if some of you guys here could give me some ideas of your approaches? Typically our scenario is, no logging really at all, and mostly.NET apps, winforms/WPF clients talking through web services or direct to a db. So, the real question is, where or what would you log? At the moment we have users reporting error messages - so I would assume log startups/shutdowns, exceptions... Do you take it to calls to the web services or db? Page loads? How do you get a good idea of what the user was trying to do at the time? Is it better to go all the way and log everything across multiple attempts/days, or log only what you need to (given hdd is cheap). I guess that's a few questions, but I wanted to get more of an idea of what the actual practice is out there in larger shops! | The key thing for logging is good planning. I would suggest that you look into the enterprise library exception and logging application block ( http://msdn.microsoft.com/en-us/library/cc467894.aspx ). There is a wee bit of a learning curve but it does work quite well. The approach I favour at the moment is to define 4 priority levels. 4=Unhandled exception (error in event log), 3=Handled exception (warning in event log), 2=Access an external resource such as a webservice, db or mainframe system (information in event log), 1=Verbose/anything else of interest (information in event log). Using the application block it's then quite easy to tweak what level of priority you want to log. So in development you'd log everything but as you get a stable system in production, you'd probably only be interested in unhandled exceptions and possibly handled exceptions. Update: For clarity, I would suggest you have logging in both your winform/wpf app and your webservices. In a web scenario, I've had problems in the past where it can be difficult to tie an error on the client back through to the app servers. Mainly because any error through webservices gets wrapped up as a SOAP exception. I can't remember off the top of my head, but I think if you use a custom exception handler (that is part of the enterprise library) you can add data onto exceptions such as the handlinginstance id of the exception from the app server. This makes it easier to tie up exceptions on a client back to your app box by using LogParser ( http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en ). Second Update: I also like to give each different event a seperate event id and to track that in a text file or spreadsheet under source control. Yes, its a pain but if you're lucky enough to have an IT team looking after your systems in production, I find they tend to expect different events to have different event ids. | What logging is good logging for your app? So we've discussed logging in passing at my place of work and I was wondering if some of you guys here could give me some ideas of your approaches? Typically our scenario is, no logging really at all, and mostly.NET apps, winforms/WPF clients talking through web services or direct to a db. So, the real question is, where or what would you log? At the moment we have users reporting error messages - so I would assume log startups/shutdowns, exceptions... Do you take it to calls to the web services or db? Page loads? How do you get a good idea of what the user was trying to do at the time? Is it better to go all the way and log everything across multiple attempts/days, or log only what you need to (given hdd is cheap). I guess that's a few questions, but I wanted to get more of an idea of what the actual practice is out there in larger shops! | TITLE:
What logging is good logging for your app?
QUESTION:
So we've discussed logging in passing at my place of work and I was wondering if some of you guys here could give me some ideas of your approaches? Typically our scenario is, no logging really at all, and mostly.NET apps, winforms/WPF clients talking through web services or direct to a db. So, the real question is, where or what would you log? At the moment we have users reporting error messages - so I would assume log startups/shutdowns, exceptions... Do you take it to calls to the web services or db? Page loads? How do you get a good idea of what the user was trying to do at the time? Is it better to go all the way and log everything across multiple attempts/days, or log only what you need to (given hdd is cheap). I guess that's a few questions, but I wanted to get more of an idea of what the actual practice is out there in larger shops!
ANSWER:
The key thing for logging is good planning. I would suggest that you look into the enterprise library exception and logging application block ( http://msdn.microsoft.com/en-us/library/cc467894.aspx ). There is a wee bit of a learning curve but it does work quite well. The approach I favour at the moment is to define 4 priority levels. 4=Unhandled exception (error in event log), 3=Handled exception (warning in event log), 2=Access an external resource such as a webservice, db or mainframe system (information in event log), 1=Verbose/anything else of interest (information in event log). Using the application block it's then quite easy to tweak what level of priority you want to log. So in development you'd log everything but as you get a stable system in production, you'd probably only be interested in unhandled exceptions and possibly handled exceptions. Update: For clarity, I would suggest you have logging in both your winform/wpf app and your webservices. In a web scenario, I've had problems in the past where it can be difficult to tie an error on the client back through to the app servers. Mainly because any error through webservices gets wrapped up as a SOAP exception. I can't remember off the top of my head, but I think if you use a custom exception handler (that is part of the enterprise library) you can add data onto exceptions such as the handlinginstance id of the exception from the app server. This makes it easier to tie up exceptions on a client back to your app box by using LogParser ( http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en ). Second Update: I also like to give each different event a seperate event id and to track that in a text file or spreadsheet under source control. Yes, its a pain but if you're lucky enough to have an IT team looking after your systems in production, I find they tend to expect different events to have different event ids. | [
".net",
"logging",
"client-applications"
] | 12 | 10 | 1,797 | 7 | 0 | 2008-08-30T10:02:20.063000 | 2008-08-30T11:20:54.727000 |
35,853 | 35,873 | P/Invoke in Mono | What's the current status of Mono 's Platform Invoke implementation on Linux and on Solaris? | Working, usable and stable. It's well tested since quite a lot of mono's own low-level functionality has to be marshaled through it to the underlying operating system. There are some P/Invoke extensions when compared to Microsoft.Net implementation (after all they deal with a single OS family and three architectures at most). Most notable of those would be that library mappings transform the library name to OS-specific variants (e.g. mylib.dll searches for mylib.so on Linux, mylib.dylib on OS X and so on) and take into account various other system specific conventions. There is also a DLLMap configuration extension which can be used if the default name translations are not enough. Usually it's convenient to have the same API of the binary lib exposed on different OSes, so that migrating between platforms only requires changes in the C code, not the.Net part. | P/Invoke in Mono What's the current status of Mono 's Platform Invoke implementation on Linux and on Solaris? | TITLE:
P/Invoke in Mono
QUESTION:
What's the current status of Mono 's Platform Invoke implementation on Linux and on Solaris?
ANSWER:
Working, usable and stable. It's well tested since quite a lot of mono's own low-level functionality has to be marshaled through it to the underlying operating system. There are some P/Invoke extensions when compared to Microsoft.Net implementation (after all they deal with a single OS family and three architectures at most). Most notable of those would be that library mappings transform the library name to OS-specific variants (e.g. mylib.dll searches for mylib.so on Linux, mylib.dylib on OS X and so on) and take into account various other system specific conventions. There is also a DLLMap configuration extension which can be used if the default name translations are not enough. Usually it's convenient to have the same API of the binary lib exposed on different OSes, so that migrating between platforms only requires changes in the C code, not the.Net part. | [
".net",
"linux",
"mono",
"pinvoke",
"solaris"
] | 21 | 29 | 4,010 | 1 | 0 | 2008-08-30T10:04:55.407000 | 2008-08-30T10:45:40.393000 |
35,870 | 35,872 | Comparison of Lat, Long Coordinates | I have a list of more than 15 thousand latitude and longitude coordinates. Given any X,Y coordinates, what is the fastest way to find the closest coordinates on the list? | You will want to use a geometric construction called a Voronoi diagram. This divides up the plane into a number of areas, one for each point, that encompass all the points that are closest to each of your given points. The code for the exact algorithms to create the Voronoi diagram and arrange the data structure lookups are too large to fit in this little edit box.:) @Linor: That's essentially what you would do after creating a Voronoi diagram. But instead of making a rectangular grid, you can choose dividing lines that closely match the lines of the Voronoi diagram (this way you will get fewer areas that cross dividing lines). If you recursively divide your Voronoi diagram in half along the best dividing line for each subdiagram, you can then do a tree search for each point you want to look up. This requires a bit of work up front but saves time later. Each lookup would be on the order of log N where N is the number of points. 16 comparisons is a lot better than 15,000! | Comparison of Lat, Long Coordinates I have a list of more than 15 thousand latitude and longitude coordinates. Given any X,Y coordinates, what is the fastest way to find the closest coordinates on the list? | TITLE:
Comparison of Lat, Long Coordinates
QUESTION:
I have a list of more than 15 thousand latitude and longitude coordinates. Given any X,Y coordinates, what is the fastest way to find the closest coordinates on the list?
ANSWER:
You will want to use a geometric construction called a Voronoi diagram. This divides up the plane into a number of areas, one for each point, that encompass all the points that are closest to each of your given points. The code for the exact algorithms to create the Voronoi diagram and arrange the data structure lookups are too large to fit in this little edit box.:) @Linor: That's essentially what you would do after creating a Voronoi diagram. But instead of making a rectangular grid, you can choose dividing lines that closely match the lines of the Voronoi diagram (this way you will get fewer areas that cross dividing lines). If you recursively divide your Voronoi diagram in half along the best dividing line for each subdiagram, you can then do a tree search for each point you want to look up. This requires a bit of work up front but saves time later. Each lookup would be on the order of log N where N is the number of points. 16 comparisons is a lot better than 15,000! | [
"sorting",
"comparison"
] | 12 | 6 | 5,903 | 13 | 0 | 2008-08-30T10:34:05.383000 | 2008-08-30T10:41:35.147000 |
35,879 | 35,891 | Base64 Encoding Image | I am building an open search add-on for Firefox/IE and the image needs to be Base64 Encoded so how can I base 64 encode the favicon I have? I am only familiar with PHP | As far as I remember there is an xml element for the image data. You can use this website to encode a file (use the upload field). Then just copy and paste the data to the XML element. You could also use PHP to do this like so: Use Mozilla's guide for help on creating OpenSearch plugins. For example, the icon element is used like this: data:image/x-icon;base64,imageData Where imageData is your base64 data. | Base64 Encoding Image I am building an open search add-on for Firefox/IE and the image needs to be Base64 Encoded so how can I base 64 encode the favicon I have? I am only familiar with PHP | TITLE:
Base64 Encoding Image
QUESTION:
I am building an open search add-on for Firefox/IE and the image needs to be Base64 Encoded so how can I base 64 encode the favicon I have? I am only familiar with PHP
ANSWER:
As far as I remember there is an xml element for the image data. You can use this website to encode a file (use the upload field). Then just copy and paste the data to the XML element. You could also use PHP to do this like so: Use Mozilla's guide for help on creating OpenSearch plugins. For example, the icon element is used like this: data:image/x-icon;base64,imageData Where imageData is your base64 data. | [
"php",
"encoding",
"base64",
"opensearch"
] | 65 | 81 | 143,645 | 5 | 0 | 2008-08-30T11:01:31.887000 | 2008-08-30T11:20:50.513000 |
35,893 | 83,939 | Grid controls compatible with .NET and Mono? | Do you know any grid control compatible with.NET and Mono? DataGridView seems to be quite buggy on Mono, and GTK# controls depends on GTK+ so you need to install it in windows machines where, usually, it's not present. | You might want to try out the preview of Mono 2.0. DataGridView is vastly better in this version, though there are still several places where it is still lacking. http://mono.ximian.com/monobuild/preview/download-preview/ | Grid controls compatible with .NET and Mono? Do you know any grid control compatible with.NET and Mono? DataGridView seems to be quite buggy on Mono, and GTK# controls depends on GTK+ so you need to install it in windows machines where, usually, it's not present. | TITLE:
Grid controls compatible with .NET and Mono?
QUESTION:
Do you know any grid control compatible with.NET and Mono? DataGridView seems to be quite buggy on Mono, and GTK# controls depends on GTK+ so you need to install it in windows machines where, usually, it's not present.
ANSWER:
You might want to try out the preview of Mono 2.0. DataGridView is vastly better in this version, though there are still several places where it is still lacking. http://mono.ximian.com/monobuild/preview/download-preview/ | [
"c#",
"datagrid",
"controls",
"mono"
] | 10 | 4 | 4,797 | 5 | 0 | 2008-08-30T11:22:42.677000 | 2008-09-17T14:39:32.113000 |
35,896 | 36,050 | How can I play compressed sound files in C# in a portable way? | Is there a portable, not patent-restricted way to play compressed sound files in C# /.Net? I want to play short "jingle" sounds on various events occuring in the program. System.Media.SoundPlayer can handle only WAV, but those are typically to big to embed in a downloadable apllication. MP3 is protected with patents, so even if there was a fully managed decoder/player it wouldn't be free to redistribute. The best format available would seem to be OGG Vorbis, but I had no luck getting any C# Vorbis libraries to work (I managed to extract a raw PCM with csvorbis but I don't know how to play it afterwards). I neither want to distribute any binaries with my application nor depend on P/Invoke, as the project should run at least on Windows and Linux. I'm fine with bundling.Net assemblies as long as they are license-compatible with GPL. [this question is a follow up to a mailing list discussion on mono-dev mailing list a year ago] | I finally revisited this topic, and, using help from BrokenGlass on writing WAVE header, updated csvorbis. I've added an OggDecodeStream that can be passed to System.Media.SoundPlayer to simply play any (compatible) Ogg Vorbis stream. Example usage: using (var file = new FileStream(oggFilename, FileMode.Open, FileAccess.Read)) { var player = new SoundPlayer(new OggDecodeStream(file)); player.PlaySync(); } 'Compatible' in this case means 'it worked when I tried it out'. The decoder is fully managed, works fine on Microsoft.Net - at the moment, there seems to be a regression in Mono's SoundPlayer that causes distortion. Outdated: System.Diagnostics.Process.Start("fullPath.mp3"); I am surprised but the method Dinah mentioned actually works. However, I was thinking about playing short "jingle" sounds on various events occurring in the program, I don't want to launch user's media player each time I need to do a 'ping!' sound. As for the code project link - this is unfortunately only a P/Invoke wrapper. | How can I play compressed sound files in C# in a portable way? Is there a portable, not patent-restricted way to play compressed sound files in C# /.Net? I want to play short "jingle" sounds on various events occuring in the program. System.Media.SoundPlayer can handle only WAV, but those are typically to big to embed in a downloadable apllication. MP3 is protected with patents, so even if there was a fully managed decoder/player it wouldn't be free to redistribute. The best format available would seem to be OGG Vorbis, but I had no luck getting any C# Vorbis libraries to work (I managed to extract a raw PCM with csvorbis but I don't know how to play it afterwards). I neither want to distribute any binaries with my application nor depend on P/Invoke, as the project should run at least on Windows and Linux. I'm fine with bundling.Net assemblies as long as they are license-compatible with GPL. [this question is a follow up to a mailing list discussion on mono-dev mailing list a year ago] | TITLE:
How can I play compressed sound files in C# in a portable way?
QUESTION:
Is there a portable, not patent-restricted way to play compressed sound files in C# /.Net? I want to play short "jingle" sounds on various events occuring in the program. System.Media.SoundPlayer can handle only WAV, but those are typically to big to embed in a downloadable apllication. MP3 is protected with patents, so even if there was a fully managed decoder/player it wouldn't be free to redistribute. The best format available would seem to be OGG Vorbis, but I had no luck getting any C# Vorbis libraries to work (I managed to extract a raw PCM with csvorbis but I don't know how to play it afterwards). I neither want to distribute any binaries with my application nor depend on P/Invoke, as the project should run at least on Windows and Linux. I'm fine with bundling.Net assemblies as long as they are license-compatible with GPL. [this question is a follow up to a mailing list discussion on mono-dev mailing list a year ago]
ANSWER:
I finally revisited this topic, and, using help from BrokenGlass on writing WAVE header, updated csvorbis. I've added an OggDecodeStream that can be passed to System.Media.SoundPlayer to simply play any (compatible) Ogg Vorbis stream. Example usage: using (var file = new FileStream(oggFilename, FileMode.Open, FileAccess.Read)) { var player = new SoundPlayer(new OggDecodeStream(file)); player.PlaySync(); } 'Compatible' in this case means 'it worked when I tried it out'. The decoder is fully managed, works fine on Microsoft.Net - at the moment, there seems to be a regression in Mono's SoundPlayer that causes distortion. Outdated: System.Diagnostics.Process.Start("fullPath.mp3"); I am surprised but the method Dinah mentioned actually works. However, I was thinking about playing short "jingle" sounds on various events occurring in the program, I don't want to launch user's media player each time I need to do a 'ping!' sound. As for the code project link - this is unfortunately only a P/Invoke wrapper. | [
"c#",
".net",
"mono",
"audio",
"oggvorbis"
] | 19 | 8 | 10,759 | 9 | 0 | 2008-08-30T11:33:55.787000 | 2008-08-30T15:41:12.307000 |
35,905 | 35,924 | How do I autorun an application in a terminal in Ubuntu? | I've created a few autorun script files on various USB devices that run bash scripts when they mount. These scripts run "in the background", how do I get them to run in a terminal window? (Like the "Application in Terminal" gnome Launcher type.) | Run them as a two stage process with your "autorun" script calling the second script in a new terminal eg gnome-terminal -e top --title Testing Would run the program "top" in a new gnome terminal window with the title "Testing" You can add additional arguments like setting the geometry to determine the size and location of the window checkout the man page for gnome-terminal and the "X" man page for more details | How do I autorun an application in a terminal in Ubuntu? I've created a few autorun script files on various USB devices that run bash scripts when they mount. These scripts run "in the background", how do I get them to run in a terminal window? (Like the "Application in Terminal" gnome Launcher type.) | TITLE:
How do I autorun an application in a terminal in Ubuntu?
QUESTION:
I've created a few autorun script files on various USB devices that run bash scripts when they mount. These scripts run "in the background", how do I get them to run in a terminal window? (Like the "Application in Terminal" gnome Launcher type.)
ANSWER:
Run them as a two stage process with your "autorun" script calling the second script in a new terminal eg gnome-terminal -e top --title Testing Would run the program "top" in a new gnome terminal window with the title "Testing" You can add additional arguments like setting the geometry to determine the size and location of the window checkout the man page for gnome-terminal and the "X" man page for more details | [
"bash",
"ubuntu",
"gnome",
"autorun"
] | 1 | 5 | 7,058 | 2 | 0 | 2008-08-30T11:53:01.777000 | 2008-08-30T12:23:17.307000 |
35,914 | 35,930 | Launch a file with command line arguments without knowing location of exe? | Here's the situation: I am trying to launch an application, but the location of the.exe isn't known to me. Now, if the file extension is registered (in Windows), I can do something like: Process.Start("Sample.xls"); However, I need to pass some command line arguments as well. I couldn't get this to work Process p = new Process(); p.StartInfo.FileName = "Sample.xls"; p.StartInfo.Arguments = "/r"; // open in read-only mode p.Start(); Any suggestions on a mechanism to solve this? Edit @ aku My StackOverflow search skills are weak; I did not find that post. Though I generally dislike peering into the registry, that's a great solution. Thanks! | Using my code from this answer you can get command associated with xls extension. Then you can pass this command to Process.Start method. | Launch a file with command line arguments without knowing location of exe? Here's the situation: I am trying to launch an application, but the location of the.exe isn't known to me. Now, if the file extension is registered (in Windows), I can do something like: Process.Start("Sample.xls"); However, I need to pass some command line arguments as well. I couldn't get this to work Process p = new Process(); p.StartInfo.FileName = "Sample.xls"; p.StartInfo.Arguments = "/r"; // open in read-only mode p.Start(); Any suggestions on a mechanism to solve this? Edit @ aku My StackOverflow search skills are weak; I did not find that post. Though I generally dislike peering into the registry, that's a great solution. Thanks! | TITLE:
Launch a file with command line arguments without knowing location of exe?
QUESTION:
Here's the situation: I am trying to launch an application, but the location of the.exe isn't known to me. Now, if the file extension is registered (in Windows), I can do something like: Process.Start("Sample.xls"); However, I need to pass some command line arguments as well. I couldn't get this to work Process p = new Process(); p.StartInfo.FileName = "Sample.xls"; p.StartInfo.Arguments = "/r"; // open in read-only mode p.Start(); Any suggestions on a mechanism to solve this? Edit @ aku My StackOverflow search skills are weak; I did not find that post. Though I generally dislike peering into the registry, that's a great solution. Thanks!
ANSWER:
Using my code from this answer you can get command associated with xls extension. Then you can pass this command to Process.Start method. | [
"c#",
".net",
"vb.net"
] | 5 | 4 | 1,210 | 2 | 0 | 2008-08-30T12:10:50.580000 | 2008-08-30T12:29:30.643000 |
35,943 | 35,961 | Logging in a PHP webapp | I want to keep logs of some things that people do in my app, in some cases so that it can be undone if needed. Is it best to store such logs in a file or a database? I'm completely at a loss as to what the pros and cons are except that it's another table to setup. Is there a third (or fourth etc) option that I'm not aware of that I should look into and learn about? | You will almost certainly want to use a database for flexible, record based access and to take advantage of the database's ability to handle concurrent data access. If you need to track information that may need to be undone, having it in a structured format is a benefit, as is having the ability to update a row indicating when and by whom a given transaction has been undone. You likely only want to write to a file if very high performance is an issue, or if you have very unstructured or large amounts of data per record that might be unweidly to store in a database. Note that Unless your application has a very large number of transactions database speed is unlikely to be an issue. Also note that if you are working with a file you'll need to handle concurrent access (read / write / locking) very carefully which is likely not something you want to have to deal with. | Logging in a PHP webapp I want to keep logs of some things that people do in my app, in some cases so that it can be undone if needed. Is it best to store such logs in a file or a database? I'm completely at a loss as to what the pros and cons are except that it's another table to setup. Is there a third (or fourth etc) option that I'm not aware of that I should look into and learn about? | TITLE:
Logging in a PHP webapp
QUESTION:
I want to keep logs of some things that people do in my app, in some cases so that it can be undone if needed. Is it best to store such logs in a file or a database? I'm completely at a loss as to what the pros and cons are except that it's another table to setup. Is there a third (or fourth etc) option that I'm not aware of that I should look into and learn about?
ANSWER:
You will almost certainly want to use a database for flexible, record based access and to take advantage of the database's ability to handle concurrent data access. If you need to track information that may need to be undone, having it in a structured format is a benefit, as is having the ability to update a row indicating when and by whom a given transaction has been undone. You likely only want to write to a file if very high performance is an issue, or if you have very unstructured or large amounts of data per record that might be unweidly to store in a database. Note that Unless your application has a very large number of transactions database speed is unlikely to be an issue. Also note that if you are working with a file you'll need to handle concurrent access (read / write / locking) very carefully which is likely not something you want to have to deal with. | [
"php",
"logging"
] | 3 | 5 | 1,368 | 5 | 0 | 2008-08-30T13:08:07.697000 | 2008-08-30T13:49:27.973000 |
35,948 | 50,425 | Django templates and variable attributes | I'm using Google App Engine and Django templates. I have a table that I want to display the objects look something like: Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] The Django template is: user {% for item in result.items %} {{item}} {% endfor %} {% for user in result.users %} {{user.name}} {% for item in result.items %} {{ user.item }} {% endfor %} {% endfor %} Now the Django documention states that when it sees a. in variables It tries several things to get the data, one of which is dictionary lookup which is exactly what I want but doesn't seem to happen... | I found a "nicer"/"better" solution for getting variables inside Its not the nicest way, but it works. You install a custom filter into django which gets the key of your dict as a parameter To make it work in google app-engine you need to add a file to your main directory, I called mine django_hack.py which contains this little piece of code from google.appengine.ext import webapp
register = webapp.template.create_template_register()
def hash(h,key): if key in h: return h[key] else: return None
register.filter(hash) Now that we have this file, all we need to do is tell the app-engine to use it... we do that by adding this little line to your main file webapp.template.register_template_library('django_hack') and in your template view add this template instead of the usual code {{ user|hash:item }} And its should work perfectly =) | Django templates and variable attributes I'm using Google App Engine and Django templates. I have a table that I want to display the objects look something like: Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] The Django template is: user {% for item in result.items %} {{item}} {% endfor %} {% for user in result.users %} {{user.name}} {% for item in result.items %} {{ user.item }} {% endfor %} {% endfor %} Now the Django documention states that when it sees a. in variables It tries several things to get the data, one of which is dictionary lookup which is exactly what I want but doesn't seem to happen... | TITLE:
Django templates and variable attributes
QUESTION:
I'm using Google App Engine and Django templates. I have a table that I want to display the objects look something like: Object Result: Items = [item1,item2] Users = [{name='username',item1=3,item2=4},..] The Django template is: user {% for item in result.items %} {{item}} {% endfor %} {% for user in result.users %} {{user.name}} {% for item in result.items %} {{ user.item }} {% endfor %} {% endfor %} Now the Django documention states that when it sees a. in variables It tries several things to get the data, one of which is dictionary lookup which is exactly what I want but doesn't seem to happen...
ANSWER:
I found a "nicer"/"better" solution for getting variables inside Its not the nicest way, but it works. You install a custom filter into django which gets the key of your dict as a parameter To make it work in google app-engine you need to add a file to your main directory, I called mine django_hack.py which contains this little piece of code from google.appengine.ext import webapp
register = webapp.template.create_template_register()
def hash(h,key): if key in h: return h[key] else: return None
register.filter(hash) Now that we have this file, all we need to do is tell the app-engine to use it... we do that by adding this little line to your main file webapp.template.register_template_library('django_hack') and in your template view add this template instead of the usual code {{ user|hash:item }} And its should work perfectly =) | [
"python",
"django",
"google-app-engine"
] | 38 | 34 | 30,330 | 6 | 0 | 2008-08-30T13:20:02.740000 | 2008-09-08T19:01:24.353000 |
35,950 | 35,965 | I don't understand std::tr1::unordered_map | I need an associative container that makes me index a certain object through a string, but that also keeps the order of insertion, so I can look for a specific object by its name or just iterate on it and retrieve objects in the same order I inserted them. I think this hybrid of linked list and hash map should do the job, but before I tried to use std::tr1::unordered_map thinking that it was working in that way I described, but it wasn't. So could someone explain me the meaning and behavior of unordered_map? @wesc: I'm sure std::map is implemented by STL, while I'm sure std::hash_map is NOT in the STL (I think older version of Visual Studio put it in a namespace called stdext). @cristopher: so, if I get it right, the difference is in the implementation (and thus performances), not in the way it behaves externally. | Boost documentation of unordered containers The difference is in the method of how you generate the look up. In the map/set containers the operator< is used to generate an ordered tree. In the unordered containers, an operator( key ) => index is used. See hashing for a description of how that works. | I don't understand std::tr1::unordered_map I need an associative container that makes me index a certain object through a string, but that also keeps the order of insertion, so I can look for a specific object by its name or just iterate on it and retrieve objects in the same order I inserted them. I think this hybrid of linked list and hash map should do the job, but before I tried to use std::tr1::unordered_map thinking that it was working in that way I described, but it wasn't. So could someone explain me the meaning and behavior of unordered_map? @wesc: I'm sure std::map is implemented by STL, while I'm sure std::hash_map is NOT in the STL (I think older version of Visual Studio put it in a namespace called stdext). @cristopher: so, if I get it right, the difference is in the implementation (and thus performances), not in the way it behaves externally. | TITLE:
I don't understand std::tr1::unordered_map
QUESTION:
I need an associative container that makes me index a certain object through a string, but that also keeps the order of insertion, so I can look for a specific object by its name or just iterate on it and retrieve objects in the same order I inserted them. I think this hybrid of linked list and hash map should do the job, but before I tried to use std::tr1::unordered_map thinking that it was working in that way I described, but it wasn't. So could someone explain me the meaning and behavior of unordered_map? @wesc: I'm sure std::map is implemented by STL, while I'm sure std::hash_map is NOT in the STL (I think older version of Visual Studio put it in a namespace called stdext). @cristopher: so, if I get it right, the difference is in the implementation (and thus performances), not in the way it behaves externally.
ANSWER:
Boost documentation of unordered containers The difference is in the method of how you generate the look up. In the map/set containers the operator< is used to generate an ordered tree. In the unordered containers, an operator( key ) => index is used. See hashing for a description of how that works. | [
"c++",
"tr1",
"unordered-map"
] | 4 | 4 | 15,720 | 7 | 0 | 2008-08-30T13:20:42.643000 | 2008-08-30T13:53:56.120000 |
35,954 | 36,055 | How do you full-text search multiple criteria on left-joined tables in SQL Server? | I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber, cacc.AccountNumber, ca.Line1, ca.CityName, ca.PostalCode from dbo.Customer as c left join dbo.CustomerAddress as ca on ca.CustomerId = c.Id left join dbo.CustomerAccount as cacc on cacc.CustomerId = c.Id where c.CountryCode = 'XX' and (cacc.AccountNumber like '%C17%' or c.Name like '%op%' or ca.Line1 like '%ae%' or ca.CityName like '%ab%' or ca.PostalCode like '%10%') On a database with 90,000 records this query takes around 7 seconds to execute (obviously all the joins and likes are taxing). I have been trying to find a way to bring the query execution time down with full-text search on the columns concerned. However, I haven't seen an example of a full-text search that has three table joins like this, especially since my join condition is not part of the search term. Is there a way to do this in full-text search? @David Yep, there are indexes on the Ids. I've tried adding indexes on the CustomerAddress stuff (CityName, PostalCode, etc.) and it brought down the query to 3 seconds, but I still find that too slow for something like this. Note that all of the text fields (with the exception of the ids) are nvarchars, and Line1 is an nvarchar 1000, so that might affect the speed, but still. | Run it through the query analyzer and see what the query plan is. My guess would be that the double root (ie. %ae%) searches are causing it do do a table scan when looking for the matching rows. Double root searches are inherently slow, as you can't use any kind of index to match them usually. | How do you full-text search multiple criteria on left-joined tables in SQL Server? I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber, cacc.AccountNumber, ca.Line1, ca.CityName, ca.PostalCode from dbo.Customer as c left join dbo.CustomerAddress as ca on ca.CustomerId = c.Id left join dbo.CustomerAccount as cacc on cacc.CustomerId = c.Id where c.CountryCode = 'XX' and (cacc.AccountNumber like '%C17%' or c.Name like '%op%' or ca.Line1 like '%ae%' or ca.CityName like '%ab%' or ca.PostalCode like '%10%') On a database with 90,000 records this query takes around 7 seconds to execute (obviously all the joins and likes are taxing). I have been trying to find a way to bring the query execution time down with full-text search on the columns concerned. However, I haven't seen an example of a full-text search that has three table joins like this, especially since my join condition is not part of the search term. Is there a way to do this in full-text search? @David Yep, there are indexes on the Ids. I've tried adding indexes on the CustomerAddress stuff (CityName, PostalCode, etc.) and it brought down the query to 3 seconds, but I still find that too slow for something like this. Note that all of the text fields (with the exception of the ids) are nvarchars, and Line1 is an nvarchar 1000, so that might affect the speed, but still. | TITLE:
How do you full-text search multiple criteria on left-joined tables in SQL Server?
QUESTION:
I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber, cacc.AccountNumber, ca.Line1, ca.CityName, ca.PostalCode from dbo.Customer as c left join dbo.CustomerAddress as ca on ca.CustomerId = c.Id left join dbo.CustomerAccount as cacc on cacc.CustomerId = c.Id where c.CountryCode = 'XX' and (cacc.AccountNumber like '%C17%' or c.Name like '%op%' or ca.Line1 like '%ae%' or ca.CityName like '%ab%' or ca.PostalCode like '%10%') On a database with 90,000 records this query takes around 7 seconds to execute (obviously all the joins and likes are taxing). I have been trying to find a way to bring the query execution time down with full-text search on the columns concerned. However, I haven't seen an example of a full-text search that has three table joins like this, especially since my join condition is not part of the search term. Is there a way to do this in full-text search? @David Yep, there are indexes on the Ids. I've tried adding indexes on the CustomerAddress stuff (CityName, PostalCode, etc.) and it brought down the query to 3 seconds, but I still find that too slow for something like this. Note that all of the text fields (with the exception of the ids) are nvarchars, and Line1 is an nvarchar 1000, so that might affect the speed, but still.
ANSWER:
Run it through the query analyzer and see what the query plan is. My guess would be that the double root (ie. %ae%) searches are causing it do do a table scan when looking for the matching rows. Double root searches are inherently slow, as you can't use any kind of index to match them usually. | [
"sql-server",
"full-text-search"
] | 0 | 1 | 1,408 | 3 | 0 | 2008-08-30T13:31:17.423000 | 2008-08-30T15:47:34.040000 |
35,973 | 36,075 | Add predefined data for typedef enums in C | What is the best approach to define additional data for typedef enums in C? Example: typedef enum { kVizsla = 0, kTerrier = 3, kYellowLab = 10 } DogType; Now I would like to define names for each, for example kVizsla should be "vizsla". I currently use a function that returns a string using a large switch block. | @dmckee: I think the suggested solution is good, but for simple data (e.g. if only the name is needed) it could be augmented with auto-generated code. While there are lots of ways to auto-generate code, for something as simple as this I believe you could write a simple XSLT that takes in an XML representation of the enum and outputs the code file. The XML would be of the form: and the resulting code would be something similar to what dmckee suggested in his solution. For information of how to write such an XSLT try here or just search it up in google and find a tutorial that fits. Writing XSLT is not much fun IMO, but it's not that bad either, at least for relatively simple tasks such as these. | Add predefined data for typedef enums in C What is the best approach to define additional data for typedef enums in C? Example: typedef enum { kVizsla = 0, kTerrier = 3, kYellowLab = 10 } DogType; Now I would like to define names for each, for example kVizsla should be "vizsla". I currently use a function that returns a string using a large switch block. | TITLE:
Add predefined data for typedef enums in C
QUESTION:
What is the best approach to define additional data for typedef enums in C? Example: typedef enum { kVizsla = 0, kTerrier = 3, kYellowLab = 10 } DogType; Now I would like to define names for each, for example kVizsla should be "vizsla". I currently use a function that returns a string using a large switch block.
ANSWER:
@dmckee: I think the suggested solution is good, but for simple data (e.g. if only the name is needed) it could be augmented with auto-generated code. While there are lots of ways to auto-generate code, for something as simple as this I believe you could write a simple XSLT that takes in an XML representation of the enum and outputs the code file. The XML would be of the form: and the resulting code would be something similar to what dmckee suggested in his solution. For information of how to write such an XSLT try here or just search it up in google and find a tutorial that fits. Writing XSLT is not much fun IMO, but it's not that bad either, at least for relatively simple tasks such as these. | [
"c",
"enums",
"typedef"
] | 5 | 2 | 2,095 | 4 | 0 | 2008-08-30T14:13:17.557000 | 2008-08-30T16:12:23.120000 |
35,974 | 166,446 | Embed Images in emails created using SQL Server Database Mail | I'm working on an email solution in SQL Server ONLY that will use Database Mail to send out HTML formatted emails. The catch is that the images in the HTML need to be embedded in the outgoing email. This wouldn't be a problem if I were using a.net app to generate & send the emails but, unfortunately, all I have is SQL Server. Is it possible for SQL Server to embed images on its own? | Yes, what you need to do is include the images as attachments and then they can be referenced within the HTML. Use the @file_attachment parameter of sp_send_dbmail | Embed Images in emails created using SQL Server Database Mail I'm working on an email solution in SQL Server ONLY that will use Database Mail to send out HTML formatted emails. The catch is that the images in the HTML need to be embedded in the outgoing email. This wouldn't be a problem if I were using a.net app to generate & send the emails but, unfortunately, all I have is SQL Server. Is it possible for SQL Server to embed images on its own? | TITLE:
Embed Images in emails created using SQL Server Database Mail
QUESTION:
I'm working on an email solution in SQL Server ONLY that will use Database Mail to send out HTML formatted emails. The catch is that the images in the HTML need to be embedded in the outgoing email. This wouldn't be a problem if I were using a.net app to generate & send the emails but, unfortunately, all I have is SQL Server. Is it possible for SQL Server to embed images on its own?
ANSWER:
Yes, what you need to do is include the images as attachments and then they can be referenced within the HTML. Use the @file_attachment parameter of sp_send_dbmail | [
"sql-server",
"database",
"email"
] | 6 | 1 | 14,141 | 3 | 0 | 2008-08-30T14:14:44.043000 | 2008-10-03T11:41:30.410000 |
35,983 | 36,063 | Rolling back bad changes with svn in Eclipse | Let's say I have committed some bad changes to Subversion repository. Then I commit good changes, that I want to keep. What would be easiest way to roll back those bad changes in Eclipse, and keep the good changes? Assuming that files relating to bad changes are not same as those relating to the good changes. How things change if good changes were made to same files as bad changes? I am mostly looking a way to do this via Eclipse plugins (Subclipse or Subversive) but commandline commands are also interesting. | You have two choices to do this. The Quick and Dirty is selecting your files (using ctrl ) in Project Explorer view, right-click them, choose Replace with... and then you choose the best option for you, from Latest from Repository, or some Branch version. After getting those files you modify them (with a space, or fix something, your call and commit them to create a newer revision. A more clean way is choosing Merge at team menu and navigate through the wizard that will help you to recovery the old version in the actual revision. Both commands have their command-line equivalents: svn revert and svn merge. | Rolling back bad changes with svn in Eclipse Let's say I have committed some bad changes to Subversion repository. Then I commit good changes, that I want to keep. What would be easiest way to roll back those bad changes in Eclipse, and keep the good changes? Assuming that files relating to bad changes are not same as those relating to the good changes. How things change if good changes were made to same files as bad changes? I am mostly looking a way to do this via Eclipse plugins (Subclipse or Subversive) but commandline commands are also interesting. | TITLE:
Rolling back bad changes with svn in Eclipse
QUESTION:
Let's say I have committed some bad changes to Subversion repository. Then I commit good changes, that I want to keep. What would be easiest way to roll back those bad changes in Eclipse, and keep the good changes? Assuming that files relating to bad changes are not same as those relating to the good changes. How things change if good changes were made to same files as bad changes? I am mostly looking a way to do this via Eclipse plugins (Subclipse or Subversive) but commandline commands are also interesting.
ANSWER:
You have two choices to do this. The Quick and Dirty is selecting your files (using ctrl ) in Project Explorer view, right-click them, choose Replace with... and then you choose the best option for you, from Latest from Repository, or some Branch version. After getting those files you modify them (with a space, or fix something, your call and commit them to create a newer revision. A more clean way is choosing Merge at team menu and navigate through the wizard that will help you to recovery the old version in the actual revision. Both commands have their command-line equivalents: svn revert and svn merge. | [
"eclipse",
"svn",
"subclipse",
"subversive"
] | 83 | 30 | 105,461 | 7 | 0 | 2008-08-30T14:22:55.083000 | 2008-08-30T15:54:19.717000 |
35,991 | 186,996 | Altering database tables in Django | I'm considering using Django for a project I'm starting (fyi, a browser-based game) and one of the features I'm liking the most is using syncdb to automatically create the database tables based on the Django models I define (a feature that I can't seem to find in any other framework). I was already thinking this was too good to be true when I saw this in the documentation: Syncdb will not alter existing tables syncdb will only create tables for models which have not yet been installed. It will never issue ALTER TABLE statements to match changes made to a model class after installation. Changes to model classes and database schemas often involve some form of ambiguity and, in those cases, Django would have to guess at the correct changes to make. There is a risk that critical data would be lost in the process. If you have made changes to a model and wish to alter the database tables to match, use the sql command to display the new SQL structure and compare that to your existing table schema to work out the changes. It seems that altering existing tables will have to be done "by hand". What I would like to know is the best way to do this. Two solutions come to mind: As the documentation suggests, make the changes manually in the DB; Do a backup of the database, wipe it, create the tables again (with syncdb, since now it's creating the tables from scratch) and import the backed-up data (this might take too long if the database is big) Any ideas? | As noted in other answers to the same topic, be sure to watch the DjangoCon 2008 Schema Evolution Panel on YouTube. Also, two new projects on the map: Simplemigrations and Migratory. | Altering database tables in Django I'm considering using Django for a project I'm starting (fyi, a browser-based game) and one of the features I'm liking the most is using syncdb to automatically create the database tables based on the Django models I define (a feature that I can't seem to find in any other framework). I was already thinking this was too good to be true when I saw this in the documentation: Syncdb will not alter existing tables syncdb will only create tables for models which have not yet been installed. It will never issue ALTER TABLE statements to match changes made to a model class after installation. Changes to model classes and database schemas often involve some form of ambiguity and, in those cases, Django would have to guess at the correct changes to make. There is a risk that critical data would be lost in the process. If you have made changes to a model and wish to alter the database tables to match, use the sql command to display the new SQL structure and compare that to your existing table schema to work out the changes. It seems that altering existing tables will have to be done "by hand". What I would like to know is the best way to do this. Two solutions come to mind: As the documentation suggests, make the changes manually in the DB; Do a backup of the database, wipe it, create the tables again (with syncdb, since now it's creating the tables from scratch) and import the backed-up data (this might take too long if the database is big) Any ideas? | TITLE:
Altering database tables in Django
QUESTION:
I'm considering using Django for a project I'm starting (fyi, a browser-based game) and one of the features I'm liking the most is using syncdb to automatically create the database tables based on the Django models I define (a feature that I can't seem to find in any other framework). I was already thinking this was too good to be true when I saw this in the documentation: Syncdb will not alter existing tables syncdb will only create tables for models which have not yet been installed. It will never issue ALTER TABLE statements to match changes made to a model class after installation. Changes to model classes and database schemas often involve some form of ambiguity and, in those cases, Django would have to guess at the correct changes to make. There is a risk that critical data would be lost in the process. If you have made changes to a model and wish to alter the database tables to match, use the sql command to display the new SQL structure and compare that to your existing table schema to work out the changes. It seems that altering existing tables will have to be done "by hand". What I would like to know is the best way to do this. Two solutions come to mind: As the documentation suggests, make the changes manually in the DB; Do a backup of the database, wipe it, create the tables again (with syncdb, since now it's creating the tables from scratch) and import the backed-up data (this might take too long if the database is big) Any ideas?
ANSWER:
As noted in other answers to the same topic, be sure to watch the DjangoCon 2008 Schema Evolution Panel on YouTube. Also, two new projects on the map: Simplemigrations and Migratory. | [
"database",
"django"
] | 62 | 17 | 33,048 | 7 | 0 | 2008-08-30T14:36:39.030000 | 2008-10-09T12:16:02.317000 |
36,001 | 36,011 | SQL Server 2005 Auto Updated DateTime Column - LastUpdated | I have a table defined (see code snippet below). How can I add a constraint or whatever so that the LastUpdate column is automatically updated anytime the row is changed? CREATE TABLE dbo.Profiles ( UserName varchar(100) NOT NULL, LastUpdate datetime NOT NULL CONSTRAINT DF_Profiles_LastUpdate DEFAULT (getdate()), FullName varchar(50) NOT NULL, Birthdate smalldatetime NULL, PageSize int NOT NULL CONSTRAINT DF_Profiles_PageSize DEFAULT ((10)), CONSTRAINT PK_Profiles PRIMARY KEY CLUSTERED (UserName ASC), CONSTRAINT FK_Profils_Users FOREIGN KEY (UserName) REFERENCES dbo.Users (UserName) ON UPDATE CASCADE ON DELETE CASCADE ) | A default constraint only works on inserts; for an update use a trigger. | SQL Server 2005 Auto Updated DateTime Column - LastUpdated I have a table defined (see code snippet below). How can I add a constraint or whatever so that the LastUpdate column is automatically updated anytime the row is changed? CREATE TABLE dbo.Profiles ( UserName varchar(100) NOT NULL, LastUpdate datetime NOT NULL CONSTRAINT DF_Profiles_LastUpdate DEFAULT (getdate()), FullName varchar(50) NOT NULL, Birthdate smalldatetime NULL, PageSize int NOT NULL CONSTRAINT DF_Profiles_PageSize DEFAULT ((10)), CONSTRAINT PK_Profiles PRIMARY KEY CLUSTERED (UserName ASC), CONSTRAINT FK_Profils_Users FOREIGN KEY (UserName) REFERENCES dbo.Users (UserName) ON UPDATE CASCADE ON DELETE CASCADE ) | TITLE:
SQL Server 2005 Auto Updated DateTime Column - LastUpdated
QUESTION:
I have a table defined (see code snippet below). How can I add a constraint or whatever so that the LastUpdate column is automatically updated anytime the row is changed? CREATE TABLE dbo.Profiles ( UserName varchar(100) NOT NULL, LastUpdate datetime NOT NULL CONSTRAINT DF_Profiles_LastUpdate DEFAULT (getdate()), FullName varchar(50) NOT NULL, Birthdate smalldatetime NULL, PageSize int NOT NULL CONSTRAINT DF_Profiles_PageSize DEFAULT ((10)), CONSTRAINT PK_Profiles PRIMARY KEY CLUSTERED (UserName ASC), CONSTRAINT FK_Profils_Users FOREIGN KEY (UserName) REFERENCES dbo.Users (UserName) ON UPDATE CASCADE ON DELETE CASCADE )
ANSWER:
A default constraint only works on inserts; for an update use a trigger. | [
"sql-server",
"database",
"timestamp",
"sql-update"
] | 13 | 4 | 20,985 | 5 | 0 | 2008-08-30T14:48:38.767000 | 2008-08-30T14:55:17.923000 |
36,014 | 41,208 | Why is .NET exception not caught by try/catch block? | I'm working on a project using the ANTLR parser library for C#. I've built a grammar to parse some text and it works well. However, when the parser comes across an illegal or unexpected token, it throws one of many exceptions. The problem is that in some cases (not all) that my try/catch block won't catch it and instead stops execution as an unhandled exception. The issue for me is that I can't replicate this issue anywhere else but in my full code. The call stack shows that the exception definitely occurs within my try/catch(Exception) block. The only thing I can think of is that there are a few ANTLR assembly calls that occur between my code and the code throwing the exception and this library does not have debugging enabled, so I can't step through it. I wonder if non-debuggable assemblies inhibit exception bubbling? The call stack looks like this; external assembly calls are in Antlr.Runtime: Expl.Itinerary.dll!TimeDefLexer.mTokens() Line 1213 C# Antlr3.Runtime.dll!Antlr.Runtime.Lexer.NextToken() + 0xfc bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.FillBuffer() + 0x22c bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.LT(int k = 1) + 0x68 bytes Expl.Itinerary.dll!TimeDefParser.prog() Line 109 + 0x17 bytes C# Expl.Itinerary.dll!Expl.Itinerary.TDLParser.Parse(string Text = "", Expl.Itinerary.IItinerary Itinerary = {Expl.Itinerary.MemoryItinerary}) Line 17 + 0xa bytes C# The code snippet from the bottom-most call in Parse() looks like: try { // Execution stopped at parser.prog() TimeDefParser.prog_return prog_ret = parser.prog(); return prog_ret == null? null: prog_ret.value; } catch (Exception ex) { throw new ParserException(ex.Message, ex); } To me, a catch (Exception) clause should've captured any exception whatsoever. Is there any reason why it wouldn't? Update: I traced through the external assembly with Reflector and found no evidence of threading whatsoever. The assembly seems to just be a runtime utility class for ANTLR's generated code. The exception thrown is from the TimeDefLexer.mTokens() method and its type is NoViableAltException, which derives from RecognitionException -> Exception. This exception is thrown when the lexer cannot understand the next token in the stream; in other words, invalid input. This exception is SUPPOSED to happen, however it should've been caught by my try/catch block. Also, the rethrowing of ParserException is really irrelevant to this situation. That is a layer of abstraction that takes any exception during parse and convert to my own ParserException. The exception handling problem I'm experiencing is never reaching that line of code. In fact, I commented out the "throw new ParserException" portion and still received the same result. One more thing, I modified the original try/catch block in question to instead catch NoViableAltException, eliminating any inheritance confusion. I still received the same result. Someone once suggested that sometimes VS is overactive on catching handled exceptions when in debug mode, but this issue also happens in release mode. Man, I'm still stumped! I hadn't mentioned it before, but I'm running VS 2008 and all my code is 3.5. The external assembly is 2.0. Also, some of my code subclasses a class in the 2.0 assembly. Could a version mismatch cause this issue? Update 2: I was able to eliminate the.NET version conflict by porting relevant portions of my.NET 3.5 code to a.NET 2.0 project and replicate the same scenario. I was able to replicate the same unhandled exception when running consistently in.NET 2.0. I learned that ANTLR has recently released 3.1. So, I upgraded from 3.0.1 and retried. It turns out the generated code is a little refactored, but the same unhandled exception occurs in my test cases. Update 3: I've replicated this scenario in a simplified VS 2008 project. Feel free to download and inspect the project for yourself. I've applied all the great suggestions, but have not been able to overcome this obstacle yet. If you can find a workaround, please do share your findings. Thanks again! Thank you, but VS 2008 automatically breaks on unhandled exceptions. Also, I don't have a Debug->Exceptions dialog. The NoViableAltException that is thrown is fully intended, and designed to be caught by user code. Since it is not caught as expected, program execution halts unexpectedly as an unhandled exception. The exception thrown is derived from Exception and there is no multi-threading going on with ANTLR. | I believe I understand the problem. The exception is being caught, the issue is confusion over the debugger's behavior and differences in the debugger settings among each person trying to repro it. In the 3rd case from your repro I believe you are getting the following message: "NoViableAltException was unhandled by user code" and a callstack that looks like this: [External Code] > TestAntlr-3.1.exe!TimeDefLexer.mTokens() Line 852 + 0xe bytes C# [External Code] TestAntlr-3.1.exe!TimeDefParser.prog() Line 141 + 0x14 bytes C# TestAntlr-3.1.exe!TestAntlr_3._1.Program.ParseTest(string Text = "foobar;") Line 49 + 0x9 bytes C# TestAntlr-3.1.exe!TestAntlr_3._1.Program.Main(string[] args = {string[0x00000000]}) Line 30 + 0xb bytes C# [External Code] If you right click in the callstack window and run turn on show external code you see this: Antlr3.Runtime.dll!Antlr.Runtime.DFA.NoViableAlt(int s = 0x00000000, Antlr.Runtime.IIntStream input = {Antlr.Runtime.ANTLRStringStream}) + 0x80 bytes Antlr3.Runtime.dll!Antlr.Runtime.DFA.Predict(Antlr.Runtime.IIntStream input = {Antlr.Runtime.ANTLRStringStream}) + 0x21e bytes > TestAntlr-3.1.exe!TimeDefLexer.mTokens() Line 852 + 0xe bytes C# Antlr3.Runtime.dll!Antlr.Runtime.Lexer.NextToken() + 0xc4 bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.FillBuffer() + 0x147 bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.LT(int k = 0x00000001) + 0x2d bytes TestAntlr-3.1.exe!TimeDefParser.prog() Line 141 + 0x14 bytes C# TestAntlr-3.1.exe!TestAntlr_3._1.Program.ParseTest(string Text = "foobar;") Line 49 + 0x9 bytes C# TestAntlr-3.1.exe!TestAntlr_3._1.Program.Main(string[] args = {string[0x00000000]}) Line 30 + 0xb bytes C# [Native to Managed Transition] [Managed to Native Transition] mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x39 bytes Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2b bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x3b bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x81 bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x40 bytes The debugger's message is telling you that an exception originating outside your code (from NoViableAlt) is going through code you own in TestAntlr-3.1.exe!TimeDefLexer.mTokens() without being handled. The wording is confusing, but it does not mean the exception is uncaught. The debugger is letting you know that code you own mTokens()" needs to be robust against this exception being thrown through it. Things to play with to see how this looks for those who didn't repro the problem: Go to Tools/Options/Debugging and turn off "Enable Just My code (Managed only)". or option. Go to Debugger/Exceptions and turn off "User-unhandled" for Common-Language Runtime Exceptions. | Why is .NET exception not caught by try/catch block? I'm working on a project using the ANTLR parser library for C#. I've built a grammar to parse some text and it works well. However, when the parser comes across an illegal or unexpected token, it throws one of many exceptions. The problem is that in some cases (not all) that my try/catch block won't catch it and instead stops execution as an unhandled exception. The issue for me is that I can't replicate this issue anywhere else but in my full code. The call stack shows that the exception definitely occurs within my try/catch(Exception) block. The only thing I can think of is that there are a few ANTLR assembly calls that occur between my code and the code throwing the exception and this library does not have debugging enabled, so I can't step through it. I wonder if non-debuggable assemblies inhibit exception bubbling? The call stack looks like this; external assembly calls are in Antlr.Runtime: Expl.Itinerary.dll!TimeDefLexer.mTokens() Line 1213 C# Antlr3.Runtime.dll!Antlr.Runtime.Lexer.NextToken() + 0xfc bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.FillBuffer() + 0x22c bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.LT(int k = 1) + 0x68 bytes Expl.Itinerary.dll!TimeDefParser.prog() Line 109 + 0x17 bytes C# Expl.Itinerary.dll!Expl.Itinerary.TDLParser.Parse(string Text = "", Expl.Itinerary.IItinerary Itinerary = {Expl.Itinerary.MemoryItinerary}) Line 17 + 0xa bytes C# The code snippet from the bottom-most call in Parse() looks like: try { // Execution stopped at parser.prog() TimeDefParser.prog_return prog_ret = parser.prog(); return prog_ret == null? null: prog_ret.value; } catch (Exception ex) { throw new ParserException(ex.Message, ex); } To me, a catch (Exception) clause should've captured any exception whatsoever. Is there any reason why it wouldn't? Update: I traced through the external assembly with Reflector and found no evidence of threading whatsoever. The assembly seems to just be a runtime utility class for ANTLR's generated code. The exception thrown is from the TimeDefLexer.mTokens() method and its type is NoViableAltException, which derives from RecognitionException -> Exception. This exception is thrown when the lexer cannot understand the next token in the stream; in other words, invalid input. This exception is SUPPOSED to happen, however it should've been caught by my try/catch block. Also, the rethrowing of ParserException is really irrelevant to this situation. That is a layer of abstraction that takes any exception during parse and convert to my own ParserException. The exception handling problem I'm experiencing is never reaching that line of code. In fact, I commented out the "throw new ParserException" portion and still received the same result. One more thing, I modified the original try/catch block in question to instead catch NoViableAltException, eliminating any inheritance confusion. I still received the same result. Someone once suggested that sometimes VS is overactive on catching handled exceptions when in debug mode, but this issue also happens in release mode. Man, I'm still stumped! I hadn't mentioned it before, but I'm running VS 2008 and all my code is 3.5. The external assembly is 2.0. Also, some of my code subclasses a class in the 2.0 assembly. Could a version mismatch cause this issue? Update 2: I was able to eliminate the.NET version conflict by porting relevant portions of my.NET 3.5 code to a.NET 2.0 project and replicate the same scenario. I was able to replicate the same unhandled exception when running consistently in.NET 2.0. I learned that ANTLR has recently released 3.1. So, I upgraded from 3.0.1 and retried. It turns out the generated code is a little refactored, but the same unhandled exception occurs in my test cases. Update 3: I've replicated this scenario in a simplified VS 2008 project. Feel free to download and inspect the project for yourself. I've applied all the great suggestions, but have not been able to overcome this obstacle yet. If you can find a workaround, please do share your findings. Thanks again! Thank you, but VS 2008 automatically breaks on unhandled exceptions. Also, I don't have a Debug->Exceptions dialog. The NoViableAltException that is thrown is fully intended, and designed to be caught by user code. Since it is not caught as expected, program execution halts unexpectedly as an unhandled exception. The exception thrown is derived from Exception and there is no multi-threading going on with ANTLR. | TITLE:
Why is .NET exception not caught by try/catch block?
QUESTION:
I'm working on a project using the ANTLR parser library for C#. I've built a grammar to parse some text and it works well. However, when the parser comes across an illegal or unexpected token, it throws one of many exceptions. The problem is that in some cases (not all) that my try/catch block won't catch it and instead stops execution as an unhandled exception. The issue for me is that I can't replicate this issue anywhere else but in my full code. The call stack shows that the exception definitely occurs within my try/catch(Exception) block. The only thing I can think of is that there are a few ANTLR assembly calls that occur between my code and the code throwing the exception and this library does not have debugging enabled, so I can't step through it. I wonder if non-debuggable assemblies inhibit exception bubbling? The call stack looks like this; external assembly calls are in Antlr.Runtime: Expl.Itinerary.dll!TimeDefLexer.mTokens() Line 1213 C# Antlr3.Runtime.dll!Antlr.Runtime.Lexer.NextToken() + 0xfc bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.FillBuffer() + 0x22c bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.LT(int k = 1) + 0x68 bytes Expl.Itinerary.dll!TimeDefParser.prog() Line 109 + 0x17 bytes C# Expl.Itinerary.dll!Expl.Itinerary.TDLParser.Parse(string Text = "", Expl.Itinerary.IItinerary Itinerary = {Expl.Itinerary.MemoryItinerary}) Line 17 + 0xa bytes C# The code snippet from the bottom-most call in Parse() looks like: try { // Execution stopped at parser.prog() TimeDefParser.prog_return prog_ret = parser.prog(); return prog_ret == null? null: prog_ret.value; } catch (Exception ex) { throw new ParserException(ex.Message, ex); } To me, a catch (Exception) clause should've captured any exception whatsoever. Is there any reason why it wouldn't? Update: I traced through the external assembly with Reflector and found no evidence of threading whatsoever. The assembly seems to just be a runtime utility class for ANTLR's generated code. The exception thrown is from the TimeDefLexer.mTokens() method and its type is NoViableAltException, which derives from RecognitionException -> Exception. This exception is thrown when the lexer cannot understand the next token in the stream; in other words, invalid input. This exception is SUPPOSED to happen, however it should've been caught by my try/catch block. Also, the rethrowing of ParserException is really irrelevant to this situation. That is a layer of abstraction that takes any exception during parse and convert to my own ParserException. The exception handling problem I'm experiencing is never reaching that line of code. In fact, I commented out the "throw new ParserException" portion and still received the same result. One more thing, I modified the original try/catch block in question to instead catch NoViableAltException, eliminating any inheritance confusion. I still received the same result. Someone once suggested that sometimes VS is overactive on catching handled exceptions when in debug mode, but this issue also happens in release mode. Man, I'm still stumped! I hadn't mentioned it before, but I'm running VS 2008 and all my code is 3.5. The external assembly is 2.0. Also, some of my code subclasses a class in the 2.0 assembly. Could a version mismatch cause this issue? Update 2: I was able to eliminate the.NET version conflict by porting relevant portions of my.NET 3.5 code to a.NET 2.0 project and replicate the same scenario. I was able to replicate the same unhandled exception when running consistently in.NET 2.0. I learned that ANTLR has recently released 3.1. So, I upgraded from 3.0.1 and retried. It turns out the generated code is a little refactored, but the same unhandled exception occurs in my test cases. Update 3: I've replicated this scenario in a simplified VS 2008 project. Feel free to download and inspect the project for yourself. I've applied all the great suggestions, but have not been able to overcome this obstacle yet. If you can find a workaround, please do share your findings. Thanks again! Thank you, but VS 2008 automatically breaks on unhandled exceptions. Also, I don't have a Debug->Exceptions dialog. The NoViableAltException that is thrown is fully intended, and designed to be caught by user code. Since it is not caught as expected, program execution halts unexpectedly as an unhandled exception. The exception thrown is derived from Exception and there is no multi-threading going on with ANTLR.
ANSWER:
I believe I understand the problem. The exception is being caught, the issue is confusion over the debugger's behavior and differences in the debugger settings among each person trying to repro it. In the 3rd case from your repro I believe you are getting the following message: "NoViableAltException was unhandled by user code" and a callstack that looks like this: [External Code] > TestAntlr-3.1.exe!TimeDefLexer.mTokens() Line 852 + 0xe bytes C# [External Code] TestAntlr-3.1.exe!TimeDefParser.prog() Line 141 + 0x14 bytes C# TestAntlr-3.1.exe!TestAntlr_3._1.Program.ParseTest(string Text = "foobar;") Line 49 + 0x9 bytes C# TestAntlr-3.1.exe!TestAntlr_3._1.Program.Main(string[] args = {string[0x00000000]}) Line 30 + 0xb bytes C# [External Code] If you right click in the callstack window and run turn on show external code you see this: Antlr3.Runtime.dll!Antlr.Runtime.DFA.NoViableAlt(int s = 0x00000000, Antlr.Runtime.IIntStream input = {Antlr.Runtime.ANTLRStringStream}) + 0x80 bytes Antlr3.Runtime.dll!Antlr.Runtime.DFA.Predict(Antlr.Runtime.IIntStream input = {Antlr.Runtime.ANTLRStringStream}) + 0x21e bytes > TestAntlr-3.1.exe!TimeDefLexer.mTokens() Line 852 + 0xe bytes C# Antlr3.Runtime.dll!Antlr.Runtime.Lexer.NextToken() + 0xc4 bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.FillBuffer() + 0x147 bytes Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.LT(int k = 0x00000001) + 0x2d bytes TestAntlr-3.1.exe!TimeDefParser.prog() Line 141 + 0x14 bytes C# TestAntlr-3.1.exe!TestAntlr_3._1.Program.ParseTest(string Text = "foobar;") Line 49 + 0x9 bytes C# TestAntlr-3.1.exe!TestAntlr_3._1.Program.Main(string[] args = {string[0x00000000]}) Line 30 + 0xb bytes C# [Native to Managed Transition] [Managed to Native Transition] mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x39 bytes Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2b bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x3b bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x81 bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x40 bytes The debugger's message is telling you that an exception originating outside your code (from NoViableAlt) is going through code you own in TestAntlr-3.1.exe!TimeDefLexer.mTokens() without being handled. The wording is confusing, but it does not mean the exception is uncaught. The debugger is letting you know that code you own mTokens()" needs to be robust against this exception being thrown through it. Things to play with to see how this looks for those who didn't repro the problem: Go to Tools/Options/Debugging and turn off "Enable Just My code (Managed only)". or option. Go to Debugger/Exceptions and turn off "User-unhandled" for Common-Language Runtime Exceptions. | [
"c#",
".net",
"exception",
"antlr"
] | 56 | 32 | 75,005 | 25 | 0 | 2008-08-30T14:57:13.050000 | 2008-09-03T05:27:31.937000 |
36,019 | 48,247 | Deleting messages from Exchange IMAP mailbox on iPhone | I have a secondary Exchange mailbox configured on my iPhone using IMAP. This all appears to work fine except when a message is deleted on the phone, it still shows normally in Outlook. It does not seem to matter what I set the "remove deleted messages" setting to on the phone. I understand this is due to a combination of the phone not expunging the deleted messages and Exchange showing deleted but not expunged messages in Outlook. I'm looking for an automated solution to this that does not have a large delay between deleting the message on the phone and it disappearing in Outlook. The message should also show in the Deleted Items when deleted from the phone. I've thought about creating a background process which connects to the mailbox via IMAP and sits in IDLE mode until there's a deleted message in the folder. It will then expunge the folder and return to IDLE mode. This wouldn't work with more than one folder (without multiple instances) but it would probably do the job. Any recommendations on an easily scriptable tool or library that supports IMAP IDLE? | I can wholeheartedly recommend writing such a process with a simple Perl client using the Mail::MAPClient module. #!/usr/bin/perl -w use strict; use Mail::IMAPClient;
# returns an unconnected Mail::IMAPClient object: my $imap = Mail::IMAPClient->new( Server => $host, User => $id, Password=> $pass, ) or die "Cannot connect to $host as $id: $@"; $imap->expunge(); This can then be run from the crontab or some other scheduler. | Deleting messages from Exchange IMAP mailbox on iPhone I have a secondary Exchange mailbox configured on my iPhone using IMAP. This all appears to work fine except when a message is deleted on the phone, it still shows normally in Outlook. It does not seem to matter what I set the "remove deleted messages" setting to on the phone. I understand this is due to a combination of the phone not expunging the deleted messages and Exchange showing deleted but not expunged messages in Outlook. I'm looking for an automated solution to this that does not have a large delay between deleting the message on the phone and it disappearing in Outlook. The message should also show in the Deleted Items when deleted from the phone. I've thought about creating a background process which connects to the mailbox via IMAP and sits in IDLE mode until there's a deleted message in the folder. It will then expunge the folder and return to IDLE mode. This wouldn't work with more than one folder (without multiple instances) but it would probably do the job. Any recommendations on an easily scriptable tool or library that supports IMAP IDLE? | TITLE:
Deleting messages from Exchange IMAP mailbox on iPhone
QUESTION:
I have a secondary Exchange mailbox configured on my iPhone using IMAP. This all appears to work fine except when a message is deleted on the phone, it still shows normally in Outlook. It does not seem to matter what I set the "remove deleted messages" setting to on the phone. I understand this is due to a combination of the phone not expunging the deleted messages and Exchange showing deleted but not expunged messages in Outlook. I'm looking for an automated solution to this that does not have a large delay between deleting the message on the phone and it disappearing in Outlook. The message should also show in the Deleted Items when deleted from the phone. I've thought about creating a background process which connects to the mailbox via IMAP and sits in IDLE mode until there's a deleted message in the folder. It will then expunge the folder and return to IDLE mode. This wouldn't work with more than one folder (without multiple instances) but it would probably do the job. Any recommendations on an easily scriptable tool or library that supports IMAP IDLE?
ANSWER:
I can wholeheartedly recommend writing such a process with a simple Perl client using the Mail::MAPClient module. #!/usr/bin/perl -w use strict; use Mail::IMAPClient;
# returns an unconnected Mail::IMAPClient object: my $imap = Mail::IMAPClient->new( Server => $host, User => $id, Password=> $pass, ) or die "Cannot connect to $host as $id: $@"; $imap->expunge(); This can then be run from the crontab or some other scheduler. | [
"ios",
"exchange-server",
"imap"
] | 2 | 2 | 2,401 | 1 | 0 | 2008-08-30T15:00:37.270000 | 2008-09-07T08:19:57.493000 |
36,028 | 36,234 | How to assign a method's output to a textbox value without code behind | How do I assign a method's output to a textbox value without code behind? <%@ Page Language="VB" %> Test Page <%=TextFromString%> <%=TextFromMethod%> it was mostly so the designer guys could use it in the aspx page. Seems like a simple thing to push a variable value into a textbox to me. It's also confusing to me why <%=TextFromString%> and Hello works but <%=TextFromString%> causes a compilation error. | There's a couple of different expression types in.ASPX files. There's: <%= TextFromMethod %> which simply reserves a literal control, and outputs the text at render time. and then there's: <%# TextFromMethod %> which is a databinding expression, evaluated when the control is DataBound(). There's also expression builders, like: <%$ ConnectionStrings:Database %> but that's not really important here.... So, the <%= %> method won't work because it would try to insert a Literal into the.Text property...obviously, not what you want. The <%# %> method doesn't work because the TextBox isn't DataBound, nor are any of it's parents. If your TextBox was in a Repeater or GridView, then this method would work. So - what to do? Just call TextBox.DataBind() at some point. Or, if you have more than 1 control, just call Page.DataBind() in your Page_Load. Private Function Page_Load(sender as Object, e as EventArgs) If Not IsPostback Then Me.DataBind() End If End Function | How to assign a method's output to a textbox value without code behind How do I assign a method's output to a textbox value without code behind? <%@ Page Language="VB" %> Test Page <%=TextFromString%> <%=TextFromMethod%> it was mostly so the designer guys could use it in the aspx page. Seems like a simple thing to push a variable value into a textbox to me. It's also confusing to me why <%=TextFromString%> and Hello works but <%=TextFromString%> causes a compilation error. | TITLE:
How to assign a method's output to a textbox value without code behind
QUESTION:
How do I assign a method's output to a textbox value without code behind? <%@ Page Language="VB" %> Test Page <%=TextFromString%> <%=TextFromMethod%> it was mostly so the designer guys could use it in the aspx page. Seems like a simple thing to push a variable value into a textbox to me. It's also confusing to me why <%=TextFromString%> and Hello works but <%=TextFromString%> causes a compilation error.
ANSWER:
There's a couple of different expression types in.ASPX files. There's: <%= TextFromMethod %> which simply reserves a literal control, and outputs the text at render time. and then there's: <%# TextFromMethod %> which is a databinding expression, evaluated when the control is DataBound(). There's also expression builders, like: <%$ ConnectionStrings:Database %> but that's not really important here.... So, the <%= %> method won't work because it would try to insert a Literal into the.Text property...obviously, not what you want. The <%# %> method doesn't work because the TextBox isn't DataBound, nor are any of it's parents. If your TextBox was in a Repeater or GridView, then this method would work. So - what to do? Just call TextBox.DataBind() at some point. Or, if you have more than 1 control, just call Page.DataBind() in your Page_Load. Private Function Page_Load(sender as Object, e as EventArgs) If Not IsPostback Then Me.DataBind() End If End Function | [
"asp.net",
"vb.net"
] | 1 | 2 | 3,653 | 2 | 0 | 2008-08-30T15:09:06.610000 | 2008-08-30T18:32:57.993000 |
36,030 | 36,059 | Yaws uses old config file | I'm developing a web app on Yaws 1.65 (installed through apt) running on Debian etch on a VPS with UML. Whenever I do /etc/init.d/yaws restart or a stop/start, it initializes according to an old version of the config file (/etc/yaws/yaws.conf). I know this because I changed the docroot from the default to another directory (call it A), then a few weeks later changed it to directory B, and the config file has stayed with B for the last several months. But then, after a restart, it switches back to A. If it switched back to the package default, that would be understandable, but it switches to an old customized version instead. The funny thing is that if I leave it stopped for several minutes, when I start it again, everything switches back to normal (using directory B). But while it's stopped, if I run ps, I don't see any yaws-related processes (yaws, heart, etc). This problem has survived several reboots, so it's got to be an old cached copy of the config somewhere, but I have yet to find anything like that. Any idea what could be going on? Update: @Gorgapor - I stopped yaws, renamed the config file and tried to start it again. It failed to start. However, I was able to restart a couple of times and this time it didn't switch back to the old version. | I'm completely inexperienced with yaws, but I have a troubleshooting suggestion: What happens if you remove the config file completely? If it still starts yaws without a config file, that could be a clear sign that something is being cached. For what it's worth, with a quick 5 minutes of googling, I found no mention of any caching behavior. | Yaws uses old config file I'm developing a web app on Yaws 1.65 (installed through apt) running on Debian etch on a VPS with UML. Whenever I do /etc/init.d/yaws restart or a stop/start, it initializes according to an old version of the config file (/etc/yaws/yaws.conf). I know this because I changed the docroot from the default to another directory (call it A), then a few weeks later changed it to directory B, and the config file has stayed with B for the last several months. But then, after a restart, it switches back to A. If it switched back to the package default, that would be understandable, but it switches to an old customized version instead. The funny thing is that if I leave it stopped for several minutes, when I start it again, everything switches back to normal (using directory B). But while it's stopped, if I run ps, I don't see any yaws-related processes (yaws, heart, etc). This problem has survived several reboots, so it's got to be an old cached copy of the config somewhere, but I have yet to find anything like that. Any idea what could be going on? Update: @Gorgapor - I stopped yaws, renamed the config file and tried to start it again. It failed to start. However, I was able to restart a couple of times and this time it didn't switch back to the old version. | TITLE:
Yaws uses old config file
QUESTION:
I'm developing a web app on Yaws 1.65 (installed through apt) running on Debian etch on a VPS with UML. Whenever I do /etc/init.d/yaws restart or a stop/start, it initializes according to an old version of the config file (/etc/yaws/yaws.conf). I know this because I changed the docroot from the default to another directory (call it A), then a few weeks later changed it to directory B, and the config file has stayed with B for the last several months. But then, after a restart, it switches back to A. If it switched back to the package default, that would be understandable, but it switches to an old customized version instead. The funny thing is that if I leave it stopped for several minutes, when I start it again, everything switches back to normal (using directory B). But while it's stopped, if I run ps, I don't see any yaws-related processes (yaws, heart, etc). This problem has survived several reboots, so it's got to be an old cached copy of the config somewhere, but I have yet to find anything like that. Any idea what could be going on? Update: @Gorgapor - I stopped yaws, renamed the config file and tried to start it again. It failed to start. However, I was able to restart a couple of times and this time it didn't switch back to the old version.
ANSWER:
I'm completely inexperienced with yaws, but I have a troubleshooting suggestion: What happens if you remove the config file completely? If it still starts yaws without a config file, that could be a clear sign that something is being cached. For what it's worth, with a quick 5 minutes of googling, I found no mention of any caching behavior. | [
"yaws"
] | 1 | 1 | 298 | 1 | 0 | 2008-08-30T15:15:01.090000 | 2008-08-30T15:50:55.030000 |
36,039 | 36,080 | Templates spread across multiple files | C++ seems to be rather grouchy when declaring templates across multiple files. More specifically, when working with templated classes, the linker expect all method definitions for the class in a single compiler object file. When you take into account headers, other declarations, inheritance, etc., things get really messy. Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files? | Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files? Yes; don't. The C++ spec permits a compiler to be able to "see" the entire template (declaration and definition) at the point of instantiation, and (due to the complexities of any implementation) most compilers retain this requirement. The upshot is that #inclusion of any template header must also #include any and all source required to instantiate the template. The easiest way to deal with this is to dump everything into the header, inline where posible, out-of-line where necessary. If you really regard this as an unacceptable affront, a common option is to split the template into the usual header/implementation pair, and then #include the implementation file at the end of the header. C++'s "export" feature may or may not provide another workaround. The feature is poorly supported and poorly defined; although it in principle should permit some kind of separate compilation of templates, it doesn't necessarily obviate the demand that the compiler be able to see the entire template body. | Templates spread across multiple files C++ seems to be rather grouchy when declaring templates across multiple files. More specifically, when working with templated classes, the linker expect all method definitions for the class in a single compiler object file. When you take into account headers, other declarations, inheritance, etc., things get really messy. Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files? | TITLE:
Templates spread across multiple files
QUESTION:
C++ seems to be rather grouchy when declaring templates across multiple files. More specifically, when working with templated classes, the linker expect all method definitions for the class in a single compiler object file. When you take into account headers, other declarations, inheritance, etc., things get really messy. Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files?
ANSWER:
Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files? Yes; don't. The C++ spec permits a compiler to be able to "see" the entire template (declaration and definition) at the point of instantiation, and (due to the complexities of any implementation) most compilers retain this requirement. The upshot is that #inclusion of any template header must also #include any and all source required to instantiate the template. The easiest way to deal with this is to dump everything into the header, inline where posible, out-of-line where necessary. If you really regard this as an unacceptable affront, a common option is to split the template into the usual header/implementation pair, and then #include the implementation file at the end of the header. C++'s "export" feature may or may not provide another workaround. The feature is poorly supported and poorly defined; although it in principle should permit some kind of separate compilation of templates, it doesn't necessarily obviate the demand that the compiler be able to see the entire template body. | [
"c++",
"templates"
] | 23 | 27 | 14,177 | 3 | 0 | 2008-08-30T15:27:34.960000 | 2008-08-30T16:19:04.570000 |
36,054 | 78,591 | Anyone have experience with Sphinx speech recognition? | Has anyone used the Sphinx speech recognition stack to build IVR applications? I am looking for open source alternatives to the expensive and somewhat limiting choices from MSFT and others. I have not been able to find a comprehensive package that ties open source speech/voip applications together. | Last I looked at Sphinx, it had issues with 8khz audio which resulted in really poor performance. There's not a lot of people talking about successful deployments of Sphinx in real environments, but you might be able to get it to work with some trailblazing effort. See here for more info: http://www.voip-info.org/wiki-Sphinx The closest thing to open-source that really works is using LumenVox with Asterisk. Asterisk is the open-source PBX that you can use to integrate with a VoIP service or gateway, or even the PSTN. LumenVox is a commercial speech engine that integrates with Asterisk: http://www.asterisk.org http://www.lumenvox.com http://www.lumenvox.com/partners/digium/Asterisk.aspx There's lots of people successfully using LumenVox with Asterisk. | Anyone have experience with Sphinx speech recognition? Has anyone used the Sphinx speech recognition stack to build IVR applications? I am looking for open source alternatives to the expensive and somewhat limiting choices from MSFT and others. I have not been able to find a comprehensive package that ties open source speech/voip applications together. | TITLE:
Anyone have experience with Sphinx speech recognition?
QUESTION:
Has anyone used the Sphinx speech recognition stack to build IVR applications? I am looking for open source alternatives to the expensive and somewhat limiting choices from MSFT and others. I have not been able to find a comprehensive package that ties open source speech/voip applications together.
ANSWER:
Last I looked at Sphinx, it had issues with 8khz audio which resulted in really poor performance. There's not a lot of people talking about successful deployments of Sphinx in real environments, but you might be able to get it to work with some trailblazing effort. See here for more info: http://www.voip-info.org/wiki-Sphinx The closest thing to open-source that really works is using LumenVox with Asterisk. Asterisk is the open-source PBX that you can use to integrate with a VoIP service or gateway, or even the PSTN. LumenVox is a commercial speech engine that integrates with Asterisk: http://www.asterisk.org http://www.lumenvox.com http://www.lumenvox.com/partners/digium/Asterisk.aspx There's lots of people successfully using LumenVox with Asterisk. | [
"speech-recognition",
"ivr",
"cmusphinx"
] | 3 | 1 | 4,212 | 2 | 0 | 2008-08-30T15:46:09.703000 | 2008-09-17T00:14:57.060000 |
36,064 | 36,209 | What is the replacement of Controller.ReadFromRequest in ASP.NET MVC? | I am attempting to update a project from ASP.NET MVC Preview 3 to Preview 5 and it seems that Controller.ReadFromRequest(string key) has been removed from the Controller class. Does anyone know of any alternatives to retrieving information based on an identifier from a form? | Looks like they've added controller.UpdateModel to address this issue, signature is: UpdateModel(object model, string[] keys) I haven't upgraded my app personally, so I'm not sure of the actual usage. I'll be interested to find out about this myself, as I'm using controller.ReadFromRequest as well. | What is the replacement of Controller.ReadFromRequest in ASP.NET MVC? I am attempting to update a project from ASP.NET MVC Preview 3 to Preview 5 and it seems that Controller.ReadFromRequest(string key) has been removed from the Controller class. Does anyone know of any alternatives to retrieving information based on an identifier from a form? | TITLE:
What is the replacement of Controller.ReadFromRequest in ASP.NET MVC?
QUESTION:
I am attempting to update a project from ASP.NET MVC Preview 3 to Preview 5 and it seems that Controller.ReadFromRequest(string key) has been removed from the Controller class. Does anyone know of any alternatives to retrieving information based on an identifier from a form?
ANSWER:
Looks like they've added controller.UpdateModel to address this issue, signature is: UpdateModel(object model, string[] keys) I haven't upgraded my app personally, so I'm not sure of the actual usage. I'll be interested to find out about this myself, as I'm using controller.ReadFromRequest as well. | [
"c#",
"asp.net-mvc",
".net-3.5",
"entity-framework-ctp5"
] | 5 | 3 | 990 | 3 | 0 | 2008-08-30T15:55:19.683000 | 2008-08-30T17:57:16.973000 |
36,077 | 60,140 | Finding out the source of an exception in C++ after it is caught? | I'm looking for an answer in MS VC++. When debugging a large C++ application, which unfortunately has a very extensive usage of C++ exceptions. Sometimes I catch an exception a little later than I actually want. Example in pseudo code: FunctionB() {... throw e;... }
FunctionA() {... FunctionB()... }
try { Function A() } catch(e) { (<--- breakpoint)... } I can catch the exception with a breakpoint when debugging. But I can't trace back if the exception occurred in FunctionA() or FunctionB(), or some other function. (Assuming extensive exception use and a huge version of the above example). One solution to my problem is to determine and save the call stack in the exception constructor (i.e. before it is caught). But this would require me to derive all exceptions from this base exception class. It would also require a lot of code, and perhaps slow down my program. Is there an easier way that requires less work? Without having to change my large code base? Are there better solutions to this problem in other languages? | If you are just interested in where the exception came from, you could just write a simple macro like #define throwException(message) \ { \ std::ostringstream oss; \ oss << __FILE __ << " " << __LINE__ << " " \ << __FUNC__ << " " << message; \ throw std::exception(oss.str().c_str()); \ } which will add the file name, line number and function name to the exception text (if the compiler provides the respective macros). Then throw exceptions using throwException("An unknown enum value has been passed!"); | Finding out the source of an exception in C++ after it is caught? I'm looking for an answer in MS VC++. When debugging a large C++ application, which unfortunately has a very extensive usage of C++ exceptions. Sometimes I catch an exception a little later than I actually want. Example in pseudo code: FunctionB() {... throw e;... }
FunctionA() {... FunctionB()... }
try { Function A() } catch(e) { (<--- breakpoint)... } I can catch the exception with a breakpoint when debugging. But I can't trace back if the exception occurred in FunctionA() or FunctionB(), or some other function. (Assuming extensive exception use and a huge version of the above example). One solution to my problem is to determine and save the call stack in the exception constructor (i.e. before it is caught). But this would require me to derive all exceptions from this base exception class. It would also require a lot of code, and perhaps slow down my program. Is there an easier way that requires less work? Without having to change my large code base? Are there better solutions to this problem in other languages? | TITLE:
Finding out the source of an exception in C++ after it is caught?
QUESTION:
I'm looking for an answer in MS VC++. When debugging a large C++ application, which unfortunately has a very extensive usage of C++ exceptions. Sometimes I catch an exception a little later than I actually want. Example in pseudo code: FunctionB() {... throw e;... }
FunctionA() {... FunctionB()... }
try { Function A() } catch(e) { (<--- breakpoint)... } I can catch the exception with a breakpoint when debugging. But I can't trace back if the exception occurred in FunctionA() or FunctionB(), or some other function. (Assuming extensive exception use and a huge version of the above example). One solution to my problem is to determine and save the call stack in the exception constructor (i.e. before it is caught). But this would require me to derive all exceptions from this base exception class. It would also require a lot of code, and perhaps slow down my program. Is there an easier way that requires less work? Without having to change my large code base? Are there better solutions to this problem in other languages?
ANSWER:
If you are just interested in where the exception came from, you could just write a simple macro like #define throwException(message) \ { \ std::ostringstream oss; \ oss << __FILE __ << " " << __LINE__ << " " \ << __FUNC__ << " " << message; \ throw std::exception(oss.str().c_str()); \ } which will add the file name, line number and function name to the exception text (if the compiler provides the respective macros). Then throw exceptions using throwException("An unknown enum value has been passed!"); | [
"c++",
"visual-studio",
"winapi",
"exception",
"visual-c++"
] | 13 | 12 | 6,865 | 14 | 0 | 2008-08-30T16:16:32.207000 | 2008-09-12T23:15:34.693000 |
36,079 | 36,279 | PHP mail using Gmail | In my PHP web app, I want to be notified via email whenever certain errors occur. I'd like to use my Gmail account for sending these. How could this be done? | Gmail's SMTP-server requires a very specific configuration. From Gmail help: Outgoing Mail (SMTP) Server (requires TLS) - smtp.gmail.com - Use Authentication: Yes - Use STARTTLS: Yes (some clients call this SSL) - Port: 465 or 587 Account Name: your full email address (including @gmail.com) Email Address: your email address (username@gmail.com) Password: your Gmail password You can probably set these settings up in Pear::Mail or PHPMailer. Check out their documentation for more details. | PHP mail using Gmail In my PHP web app, I want to be notified via email whenever certain errors occur. I'd like to use my Gmail account for sending these. How could this be done? | TITLE:
PHP mail using Gmail
QUESTION:
In my PHP web app, I want to be notified via email whenever certain errors occur. I'd like to use my Gmail account for sending these. How could this be done?
ANSWER:
Gmail's SMTP-server requires a very specific configuration. From Gmail help: Outgoing Mail (SMTP) Server (requires TLS) - smtp.gmail.com - Use Authentication: Yes - Use STARTTLS: Yes (some clients call this SSL) - Port: 465 or 587 Account Name: your full email address (including @gmail.com) Email Address: your email address (username@gmail.com) Password: your Gmail password You can probably set these settings up in Pear::Mail or PHPMailer. Check out their documentation for more details. | [
"php",
"email",
"gmail"
] | 11 | 10 | 26,853 | 2 | 0 | 2008-08-30T16:18:35.260000 | 2008-08-30T19:22:42.540000 |
36,081 | 36,097 | How to Catch an exception in a using block with .NET 2.0? | I'm trying to leverage the using block more and more these days when I have an object that implements IDisposable but one thing I have not figured out is how to catch an exception as I would in a normal try/catch/finally... any code samples to point me in the right direction? Edit: The question was modified after reading through the replies. It was "How to Throw an exception in a using block with.NET 2.0?" but I was actually looking for a way to catch these exceptions inside a using block. I'm looking for more detail on rolling my own catching block inside a using block. Edit: What I wanted to avoid is having to use a try/catch/finally inside my using block like @Blair showed. But maybe this is a non issue... Edit: @Blair, this is exactly what I was looking for, thanks for the detailed reply! | I don't really understand the question - you throw an exception as you normally would. If MyThing implements IDisposable, then: using ( MyThing thing = new MyThing() ) {... throw new ApplicationException("oops"); } And thing.Dispose will be called as you leave the block, as the exception's thrown. If you want to combine a try/catch/finally and a using, you can either nest them: try {... using ( MyThing thing = new MyThing() ) {... }... } catch ( Exception e ) {.... } finally {.... } (Or put the try/catch/finally in the using): using ( MyThing thing = new MyThing() ) {... try {... } catch ( Exception e ) {.... } finally {.... }... } // thing.Dispose is called now Or you can unroll the using and explicitly call Dispose in the finally block as @Quarrelsome demonstrated, adding any extra exception-handling or -recovery code that you need in the finally (or in the catch ). EDIT: In response to @Toran Billups, if you need to process exceptions aside from ensuring that your Dispose method is called, you'll either have to use a using and try/catch/finally or unroll the using - I don't thinks there's any other way to accomplish what you want. | How to Catch an exception in a using block with .NET 2.0? I'm trying to leverage the using block more and more these days when I have an object that implements IDisposable but one thing I have not figured out is how to catch an exception as I would in a normal try/catch/finally... any code samples to point me in the right direction? Edit: The question was modified after reading through the replies. It was "How to Throw an exception in a using block with.NET 2.0?" but I was actually looking for a way to catch these exceptions inside a using block. I'm looking for more detail on rolling my own catching block inside a using block. Edit: What I wanted to avoid is having to use a try/catch/finally inside my using block like @Blair showed. But maybe this is a non issue... Edit: @Blair, this is exactly what I was looking for, thanks for the detailed reply! | TITLE:
How to Catch an exception in a using block with .NET 2.0?
QUESTION:
I'm trying to leverage the using block more and more these days when I have an object that implements IDisposable but one thing I have not figured out is how to catch an exception as I would in a normal try/catch/finally... any code samples to point me in the right direction? Edit: The question was modified after reading through the replies. It was "How to Throw an exception in a using block with.NET 2.0?" but I was actually looking for a way to catch these exceptions inside a using block. I'm looking for more detail on rolling my own catching block inside a using block. Edit: What I wanted to avoid is having to use a try/catch/finally inside my using block like @Blair showed. But maybe this is a non issue... Edit: @Blair, this is exactly what I was looking for, thanks for the detailed reply!
ANSWER:
I don't really understand the question - you throw an exception as you normally would. If MyThing implements IDisposable, then: using ( MyThing thing = new MyThing() ) {... throw new ApplicationException("oops"); } And thing.Dispose will be called as you leave the block, as the exception's thrown. If you want to combine a try/catch/finally and a using, you can either nest them: try {... using ( MyThing thing = new MyThing() ) {... }... } catch ( Exception e ) {.... } finally {.... } (Or put the try/catch/finally in the using): using ( MyThing thing = new MyThing() ) {... try {... } catch ( Exception e ) {.... } finally {.... }... } // thing.Dispose is called now Or you can unroll the using and explicitly call Dispose in the finally block as @Quarrelsome demonstrated, adding any extra exception-handling or -recovery code that you need in the finally (or in the catch ). EDIT: In response to @Toran Billups, if you need to process exceptions aside from ensuring that your Dispose method is called, you'll either have to use a using and try/catch/finally or unroll the using - I don't thinks there's any other way to accomplish what you want. | [
"exception",
"ado.net",
".net-2.0",
"error-handling"
] | 4 | 7 | 3,945 | 3 | 0 | 2008-08-30T16:19:22.387000 | 2008-08-30T16:32:01.327000 |
36,093 | 36,171 | Subversion or Adobe Version CUE 3 for Photoshop/Illustrator Files | This might seem like a stupid question I admit. But I'm in a small shop me plus two designers. Our backups are getting out of hand because they just copy/paste files if they need to make a change (version). I was all set to try Subversion to handle all of our files my text (code) files and their photoshop/illustrator and asset files. That is until I noticed there was a new version of Adobe Version Cue v3. We've tried previously to use version cue but it got complicated and the designers quickly stopped using it. Looking for anyone that has some experience with version 3 of Version Cue. Thanks for the great feedback. Maybe I should have asked what's the best tool to use for Versioning Photoshop and related files. I did notice the binary file issue and was worried about trying to explain it and keep it "working". I signed up for the beta at Gridiron thanks for that! Here is the other question related to this one. | I have used Subversion for this exact thing, and Theo is right, you have to remember to lock your files. I am on CS2 and so have not used Version Cue, but I have not been able to find a whole lot online about other folks using it either, for some reason. The other problem I had using Subversion related to disk space. Subversion stores an alternate "shadow copy" of your files in your working directory. For Photoshop and Illustrator this is normally not that big of a deal, but I was using Premiere and After Effects as well, and the disk space required for the shadow copies doubled my disk usage. You might also check out Gridiron's new Gridiron Flow product, which John Nack raves about. I would love to use it - it's due out about now, and it will likely run in the several-hundred dollar range, I think... Update 3/6/2009: Gridiron Flow is out, and it does versioning on a single machine, but it's not clear from their demos whether it does collaborative versioning. Also, I just stumbled across this very good comparison of subversion, git & mercurial for managing a home directory - including various versions of large Photoshop files. | Subversion or Adobe Version CUE 3 for Photoshop/Illustrator Files This might seem like a stupid question I admit. But I'm in a small shop me plus two designers. Our backups are getting out of hand because they just copy/paste files if they need to make a change (version). I was all set to try Subversion to handle all of our files my text (code) files and their photoshop/illustrator and asset files. That is until I noticed there was a new version of Adobe Version Cue v3. We've tried previously to use version cue but it got complicated and the designers quickly stopped using it. Looking for anyone that has some experience with version 3 of Version Cue. Thanks for the great feedback. Maybe I should have asked what's the best tool to use for Versioning Photoshop and related files. I did notice the binary file issue and was worried about trying to explain it and keep it "working". I signed up for the beta at Gridiron thanks for that! Here is the other question related to this one. | TITLE:
Subversion or Adobe Version CUE 3 for Photoshop/Illustrator Files
QUESTION:
This might seem like a stupid question I admit. But I'm in a small shop me plus two designers. Our backups are getting out of hand because they just copy/paste files if they need to make a change (version). I was all set to try Subversion to handle all of our files my text (code) files and their photoshop/illustrator and asset files. That is until I noticed there was a new version of Adobe Version Cue v3. We've tried previously to use version cue but it got complicated and the designers quickly stopped using it. Looking for anyone that has some experience with version 3 of Version Cue. Thanks for the great feedback. Maybe I should have asked what's the best tool to use for Versioning Photoshop and related files. I did notice the binary file issue and was worried about trying to explain it and keep it "working". I signed up for the beta at Gridiron thanks for that! Here is the other question related to this one.
ANSWER:
I have used Subversion for this exact thing, and Theo is right, you have to remember to lock your files. I am on CS2 and so have not used Version Cue, but I have not been able to find a whole lot online about other folks using it either, for some reason. The other problem I had using Subversion related to disk space. Subversion stores an alternate "shadow copy" of your files in your working directory. For Photoshop and Illustrator this is normally not that big of a deal, but I was using Premiere and After Effects as well, and the disk space required for the shadow copies doubled my disk usage. You might also check out Gridiron's new Gridiron Flow product, which John Nack raves about. I would love to use it - it's due out about now, and it will likely run in the several-hundred dollar range, I think... Update 3/6/2009: Gridiron Flow is out, and it does versioning on a single machine, but it's not clear from their demos whether it does collaborative versioning. Also, I just stumbled across this very good comparison of subversion, git & mercurial for managing a home directory - including various versions of large Photoshop files. | [
"svn",
"versioning",
"photoshop"
] | 5 | 1 | 5,898 | 6 | 0 | 2008-08-30T16:27:14.333000 | 2008-08-30T17:20:02.273000 |
36,101 | 36,131 | How do I set the name of a window in ROR? | How do I "name" a browser window in ROR, such that I can open a page in it later, from another (popup) window (using the target="name" html parameter) | You have to use JavaScript for this: Of course you could easily package this up into a Rails helper method. For example, in app/helpers/application_helper.rb add a new method: def window_name(name) content_for(:window_name) do " " end end Next, in your layout file, add this line somewhere within the HTML element: <%= yield:window_name %> Finally, in your view templates, simply add a line like this (can be anywhere you want) to output the correct JavaScript: <% window_name 'MyWindow' %> | How do I set the name of a window in ROR? How do I "name" a browser window in ROR, such that I can open a page in it later, from another (popup) window (using the target="name" html parameter) | TITLE:
How do I set the name of a window in ROR?
QUESTION:
How do I "name" a browser window in ROR, such that I can open a page in it later, from another (popup) window (using the target="name" html parameter)
ANSWER:
You have to use JavaScript for this: Of course you could easily package this up into a Rails helper method. For example, in app/helpers/application_helper.rb add a new method: def window_name(name) content_for(:window_name) do " " end end Next, in your layout file, add this line somewhere within the HTML element: <%= yield:window_name %> Finally, in your view templates, simply add a line like this (can be anywhere you want) to output the correct JavaScript: <% window_name 'MyWindow' %> | [
"javascript",
"html",
"ruby-on-rails",
"ruby"
] | 4 | 5 | 346 | 2 | 0 | 2008-08-30T16:37:31.330000 | 2008-08-30T16:55:17.993000 |
36,106 | 36,311 | What are some alternatives to a bit array? | I have an information retrieval application that creates bit arrays on the order of 10s of million bits. The number of "set" bits in the array varies widely, from all clear to all set. Currently, I'm using a straight-forward bit array ( java.util.BitSet ), so each of my bit arrays takes several megabytes. My plan is to look at the cardinality of the first N bits, then make a decision about what data structure to use for the remainder. Clearly some data structures are better for very sparse bit arrays, and others when roughly half the bits are set (when most bits are set, I can use negation to treat it as a sparse set of zeroes). What structures might be good at each extreme? Are there any in the middle? Here are a few constraints or hints: The bits are set only once, and in index order. I need 100% accuracy, so something like a Bloom filter isn't good enough. After the set is built, I need to be able to efficiently iterate over the "set" bits. The bits are randomly distributed, so run-length–encoding algorithms aren't likely to be much better than a simple list of bit indexes. I'm trying to optimize memory utilization, but speed still carries some weight. Something with an open source Java implementation is helpful, but not strictly necessary. I'm more interested in the fundamentals. | Unless the data is truly random and has a symmetric 1/0 distribution, then this simply becomes a lossless data compression problem and is very analogous to CCITT Group 3 compression used for black and white (i.e.: Binary) FAX images. CCITT Group 3 uses a Huffman Coding scheme. In the case of FAX they are using a fixed set of Huffman codes, but for a given data set, you can generate a specific set of codes for each data set to improve the compression ratio achieved. As long as you only need to access the bits sequentially, as you implied, this will be a pretty efficient approach. Random access would create some additional challenges, but you could probably generate a binary search tree index to various offset points in the array that would allow you to get close to the desired location and then walk in from there. Note: The Huffman scheme still works well even if the data is random, as long as the 1/0 distribution is not perfectly even. That is, the less even the distribution, the better the compression ratio. Finally, if the bits are truly random with an even distribution, then, well, according to Mr. Claude Shannon, you are not going to be able to compress it any significant amount using any scheme. | What are some alternatives to a bit array? I have an information retrieval application that creates bit arrays on the order of 10s of million bits. The number of "set" bits in the array varies widely, from all clear to all set. Currently, I'm using a straight-forward bit array ( java.util.BitSet ), so each of my bit arrays takes several megabytes. My plan is to look at the cardinality of the first N bits, then make a decision about what data structure to use for the remainder. Clearly some data structures are better for very sparse bit arrays, and others when roughly half the bits are set (when most bits are set, I can use negation to treat it as a sparse set of zeroes). What structures might be good at each extreme? Are there any in the middle? Here are a few constraints or hints: The bits are set only once, and in index order. I need 100% accuracy, so something like a Bloom filter isn't good enough. After the set is built, I need to be able to efficiently iterate over the "set" bits. The bits are randomly distributed, so run-length–encoding algorithms aren't likely to be much better than a simple list of bit indexes. I'm trying to optimize memory utilization, but speed still carries some weight. Something with an open source Java implementation is helpful, but not strictly necessary. I'm more interested in the fundamentals. | TITLE:
What are some alternatives to a bit array?
QUESTION:
I have an information retrieval application that creates bit arrays on the order of 10s of million bits. The number of "set" bits in the array varies widely, from all clear to all set. Currently, I'm using a straight-forward bit array ( java.util.BitSet ), so each of my bit arrays takes several megabytes. My plan is to look at the cardinality of the first N bits, then make a decision about what data structure to use for the remainder. Clearly some data structures are better for very sparse bit arrays, and others when roughly half the bits are set (when most bits are set, I can use negation to treat it as a sparse set of zeroes). What structures might be good at each extreme? Are there any in the middle? Here are a few constraints or hints: The bits are set only once, and in index order. I need 100% accuracy, so something like a Bloom filter isn't good enough. After the set is built, I need to be able to efficiently iterate over the "set" bits. The bits are randomly distributed, so run-length–encoding algorithms aren't likely to be much better than a simple list of bit indexes. I'm trying to optimize memory utilization, but speed still carries some weight. Something with an open source Java implementation is helpful, but not strictly necessary. I'm more interested in the fundamentals.
ANSWER:
Unless the data is truly random and has a symmetric 1/0 distribution, then this simply becomes a lossless data compression problem and is very analogous to CCITT Group 3 compression used for black and white (i.e.: Binary) FAX images. CCITT Group 3 uses a Huffman Coding scheme. In the case of FAX they are using a fixed set of Huffman codes, but for a given data set, you can generate a specific set of codes for each data set to improve the compression ratio achieved. As long as you only need to access the bits sequentially, as you implied, this will be a pretty efficient approach. Random access would create some additional challenges, but you could probably generate a binary search tree index to various offset points in the array that would allow you to get close to the desired location and then walk in from there. Note: The Huffman scheme still works well even if the data is random, as long as the 1/0 distribution is not perfectly even. That is, the less even the distribution, the better the compression ratio. Finally, if the bits are truly random with an even distribution, then, well, according to Mr. Claude Shannon, you are not going to be able to compress it any significant amount using any scheme. | [
"data-structures",
"information-retrieval"
] | 8 | 16 | 3,464 | 7 | 0 | 2008-08-30T16:39:01.137000 | 2008-08-30T20:05:37.723000 |
36,108 | 36,741 | How to get controls in WPF to fill available space? | Some WPF controls (like the Button ) seem to happily consume all the available space in its' container if you don't specify the height it is to have. And some, like the ones I need to use right now, the (multiline) TextBox and the ListBox seem more worried about just taking the space necessary to fit their contents, and no more. If you put these guys in a cell in a UniformGrid, they will expand to fit the available space. However, UniformGrid instances are not right for all situations. What if you have a grid with some rows set to a * height to divide the height between itself and other * rows? What if you have a StackPanel and you have a Label, a List and a Button, how can you get the list to take up all the space not eaten by the label and the button? I would think this would really be a basic layout requirement, but I can't figure out how to get them to fill the space that they could (putting them in a DockPanel and setting it to fill also doesn't work, it seems, since the DockPanel only takes up the space needed by its' subcontrols). A resizable GUI would be quite horrible if you had to play with Height, Width, MinHeight, MinWidth etc. Can you bind your Height and Width properties to the grid cell you occupy? Or is there another way to do this? | Each control deriving from Panel implements distinct layout logic performed in Measure() and Arrange(): Measure() determines the size of the panel and each of its children Arrange() determines the rectangle where each control renders The last child of the DockPanel fills the remaining space. You can disable this behavior by setting the LastChild property to false. The StackPanel asks each child for its desired size and then stacks them. The stack panel calls Measure() on each child, with an available size of Infinity and then uses the child's desired size. A Grid occupies all available space, however, it will set each child to their desired size and then center them in the cell. You can implement your own layout logic by deriving from Panel and then overriding MeasureOverride() and ArrangeOverride(). See this article for a simple example. | How to get controls in WPF to fill available space? Some WPF controls (like the Button ) seem to happily consume all the available space in its' container if you don't specify the height it is to have. And some, like the ones I need to use right now, the (multiline) TextBox and the ListBox seem more worried about just taking the space necessary to fit their contents, and no more. If you put these guys in a cell in a UniformGrid, they will expand to fit the available space. However, UniformGrid instances are not right for all situations. What if you have a grid with some rows set to a * height to divide the height between itself and other * rows? What if you have a StackPanel and you have a Label, a List and a Button, how can you get the list to take up all the space not eaten by the label and the button? I would think this would really be a basic layout requirement, but I can't figure out how to get them to fill the space that they could (putting them in a DockPanel and setting it to fill also doesn't work, it seems, since the DockPanel only takes up the space needed by its' subcontrols). A resizable GUI would be quite horrible if you had to play with Height, Width, MinHeight, MinWidth etc. Can you bind your Height and Width properties to the grid cell you occupy? Or is there another way to do this? | TITLE:
How to get controls in WPF to fill available space?
QUESTION:
Some WPF controls (like the Button ) seem to happily consume all the available space in its' container if you don't specify the height it is to have. And some, like the ones I need to use right now, the (multiline) TextBox and the ListBox seem more worried about just taking the space necessary to fit their contents, and no more. If you put these guys in a cell in a UniformGrid, they will expand to fit the available space. However, UniformGrid instances are not right for all situations. What if you have a grid with some rows set to a * height to divide the height between itself and other * rows? What if you have a StackPanel and you have a Label, a List and a Button, how can you get the list to take up all the space not eaten by the label and the button? I would think this would really be a basic layout requirement, but I can't figure out how to get them to fill the space that they could (putting them in a DockPanel and setting it to fill also doesn't work, it seems, since the DockPanel only takes up the space needed by its' subcontrols). A resizable GUI would be quite horrible if you had to play with Height, Width, MinHeight, MinWidth etc. Can you bind your Height and Width properties to the grid cell you occupy? Or is there another way to do this?
ANSWER:
Each control deriving from Panel implements distinct layout logic performed in Measure() and Arrange(): Measure() determines the size of the panel and each of its children Arrange() determines the rectangle where each control renders The last child of the DockPanel fills the remaining space. You can disable this behavior by setting the LastChild property to false. The StackPanel asks each child for its desired size and then stacks them. The stack panel calls Measure() on each child, with an available size of Infinity and then uses the child's desired size. A Grid occupies all available space, however, it will set each child to their desired size and then center them in the cell. You can implement your own layout logic by deriving from Panel and then overriding MeasureOverride() and ArrangeOverride(). See this article for a simple example. | [
"wpf",
"user-interface",
"layout"
] | 356 | 176 | 335,455 | 5 | 0 | 2008-08-30T16:39:28.423000 | 2008-08-31T10:04:15.150000 |
36,109 | 42,005 | Quoting command-line arguments in shell scripts | The following shell script takes a list of arguments, turns Unix paths into WINE/Windows paths and invokes the given executable under WINE. #! /bin/sh
if [ "${1+set}"!= "set" ] then echo "Usage; winewrap EXEC [ARGS...]" exit 1 fi
EXEC="$1" shift
ARGS=""
for p in "$@"; do if [ -e "$p" ] then p=$(winepath -w $p) fi ARGS="$ARGS '$p'" done
CMD="wine '$EXEC' $ARGS" echo $CMD $CMD However, there's something wrong with the quotation of command-line arguments. $ winewrap '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' -smt /tmp/smtlib3cee8b.smt Executing: wine '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' '-smt' 'Z: mp\smtlib3cee8b.smt' wine: cannot find ''/home/chris/.wine/drive_c/Program' Note that: The path to the executable is being chopped off at the first space, even though it is single-quoted. The literal "\t" in the last path is being transformed into a tab character. Obviously, the quotations aren't being parsed the way I intended by the shell. How can I avoid these errors? EDIT: The "\t" is being expanded through two levels of indirection: first, "$p" (and/or "$ARGS" ) is being expanded into Z:\tmp\smtlib3cee8b.smt; then, \t is being expanded into the tab character. This is (seemingly) equivalent to Y='y\ty' Z="z${Y}z" echo $Z which yields zy\tyz and not zy yz UPDATE: eval "$CMD" does the trick. The " \t " problem seems to be echo's fault: "If the first operand is -n, or if any of the operands contain a backslash ( '\' ) character, the results are implementation-defined." ( POSIX specification of echo ) | I you do want to have the assignment to CMD you should use eval $CMD instead of just $CMD in the last line of your script. This should solve your problem with spaces in the paths, I don't know what to do about the "\t" problem. | Quoting command-line arguments in shell scripts The following shell script takes a list of arguments, turns Unix paths into WINE/Windows paths and invokes the given executable under WINE. #! /bin/sh
if [ "${1+set}"!= "set" ] then echo "Usage; winewrap EXEC [ARGS...]" exit 1 fi
EXEC="$1" shift
ARGS=""
for p in "$@"; do if [ -e "$p" ] then p=$(winepath -w $p) fi ARGS="$ARGS '$p'" done
CMD="wine '$EXEC' $ARGS" echo $CMD $CMD However, there's something wrong with the quotation of command-line arguments. $ winewrap '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' -smt /tmp/smtlib3cee8b.smt Executing: wine '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' '-smt' 'Z: mp\smtlib3cee8b.smt' wine: cannot find ''/home/chris/.wine/drive_c/Program' Note that: The path to the executable is being chopped off at the first space, even though it is single-quoted. The literal "\t" in the last path is being transformed into a tab character. Obviously, the quotations aren't being parsed the way I intended by the shell. How can I avoid these errors? EDIT: The "\t" is being expanded through two levels of indirection: first, "$p" (and/or "$ARGS" ) is being expanded into Z:\tmp\smtlib3cee8b.smt; then, \t is being expanded into the tab character. This is (seemingly) equivalent to Y='y\ty' Z="z${Y}z" echo $Z which yields zy\tyz and not zy yz UPDATE: eval "$CMD" does the trick. The " \t " problem seems to be echo's fault: "If the first operand is -n, or if any of the operands contain a backslash ( '\' ) character, the results are implementation-defined." ( POSIX specification of echo ) | TITLE:
Quoting command-line arguments in shell scripts
QUESTION:
The following shell script takes a list of arguments, turns Unix paths into WINE/Windows paths and invokes the given executable under WINE. #! /bin/sh
if [ "${1+set}"!= "set" ] then echo "Usage; winewrap EXEC [ARGS...]" exit 1 fi
EXEC="$1" shift
ARGS=""
for p in "$@"; do if [ -e "$p" ] then p=$(winepath -w $p) fi ARGS="$ARGS '$p'" done
CMD="wine '$EXEC' $ARGS" echo $CMD $CMD However, there's something wrong with the quotation of command-line arguments. $ winewrap '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' -smt /tmp/smtlib3cee8b.smt Executing: wine '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' '-smt' 'Z: mp\smtlib3cee8b.smt' wine: cannot find ''/home/chris/.wine/drive_c/Program' Note that: The path to the executable is being chopped off at the first space, even though it is single-quoted. The literal "\t" in the last path is being transformed into a tab character. Obviously, the quotations aren't being parsed the way I intended by the shell. How can I avoid these errors? EDIT: The "\t" is being expanded through two levels of indirection: first, "$p" (and/or "$ARGS" ) is being expanded into Z:\tmp\smtlib3cee8b.smt; then, \t is being expanded into the tab character. This is (seemingly) equivalent to Y='y\ty' Z="z${Y}z" echo $Z which yields zy\tyz and not zy yz UPDATE: eval "$CMD" does the trick. The " \t " problem seems to be echo's fault: "If the first operand is -n, or if any of the operands contain a backslash ( '\' ) character, the results are implementation-defined." ( POSIX specification of echo )
ANSWER:
I you do want to have the assignment to CMD you should use eval $CMD instead of just $CMD in the last line of your script. This should solve your problem with spaces in the paths, I don't know what to do about the "\t" problem. | [
"unix",
"shell",
"wine"
] | 3 | 1 | 5,356 | 4 | 0 | 2008-08-30T16:39:42.913000 | 2008-09-03T16:02:40.363000 |
36,114 | 36,246 | Variable Holding data in a while statement | I know I must be missing something, but in a while statement how does the variable hold the data, when it finishes the first pass and goes into the second pass? { int num1 = 0; int num2 = 0; int num3 = 0;
while (num1 < 10)
{cout << "enter your first number: "; cin >> num1;
cout << "Enter your second number: "; cin >> num2;
num1 = num1 + num2;
cout << "Number 1 is now: " << num1 < > num3;
num1 = num1 + num3;
cout << "Number 1 is now: " << num1 << endl; num1++; }; In this code. The Variable doesn't hold the data. I'm not sure what I'm doing wrong! | Is num1 the variable you're having trouble with? This line: cin >> num1; is setting num1 to the value input by the user. So the value calculated for it in the previous run through the loop is being overwritten each time by the new input. | Variable Holding data in a while statement I know I must be missing something, but in a while statement how does the variable hold the data, when it finishes the first pass and goes into the second pass? { int num1 = 0; int num2 = 0; int num3 = 0;
while (num1 < 10)
{cout << "enter your first number: "; cin >> num1;
cout << "Enter your second number: "; cin >> num2;
num1 = num1 + num2;
cout << "Number 1 is now: " << num1 < > num3;
num1 = num1 + num3;
cout << "Number 1 is now: " << num1 << endl; num1++; }; In this code. The Variable doesn't hold the data. I'm not sure what I'm doing wrong! | TITLE:
Variable Holding data in a while statement
QUESTION:
I know I must be missing something, but in a while statement how does the variable hold the data, when it finishes the first pass and goes into the second pass? { int num1 = 0; int num2 = 0; int num3 = 0;
while (num1 < 10)
{cout << "enter your first number: "; cin >> num1;
cout << "Enter your second number: "; cin >> num2;
num1 = num1 + num2;
cout << "Number 1 is now: " << num1 < > num3;
num1 = num1 + num3;
cout << "Number 1 is now: " << num1 << endl; num1++; }; In this code. The Variable doesn't hold the data. I'm not sure what I'm doing wrong!
ANSWER:
Is num1 the variable you're having trouble with? This line: cin >> num1; is setting num1 to the value input by the user. So the value calculated for it in the previous run through the loop is being overwritten each time by the new input. | [
"c++"
] | 0 | 2 | 344 | 4 | 0 | 2008-08-30T16:43:28.943000 | 2008-08-30T18:47:48.317000 |
36,122 | 177,740 | What is the most efficient way to keep track of a specific character's index in a string? | Take the following string as an example: "The quick brown fox" Right now the q in quick is at index 4 of the string (starting at 0) and the f in fox is at index 16. Now lets say the user enters some more text into this string. "The very quick dark brown fox" Now the q is at index 9 and the f is at index 26. What is the most efficient method of keeping track of the index of the original q in quick and f in fox no matter how many characters are added by the user? Language doesn't matter to me, this is more of a theory question than anything so use whatever language you want just try to keep it to generally popular and current languages. The sample string I gave is short but I'm hoping for a way that can efficiently handle any size string. So updating an array with the offset would work with a short string but will bog down with to many characters. Even though in the example I was looking for the index of unique characters in the string I also want to be able to track the index of the same character in different locations such as the o in brown and the o in fox. So searching is out of the question. I was hoping for the answer to be both time and memory efficient but if I had to choose just one I care more about performance speed. | Let's say that you have a string and some of its letters are interesting. To make things easier let's say that the letter at index 0 is always interesting and you never add something before it—a sentinel. Write down pairs of (interesting letter, distance to the previous interesting letter). If the string is "+the very Quick dark brown Fox" and you are interested in q from 'quick' and f from 'fox' then you would write: (+,0), (q,10), (f,17). (The sign + is the sentinel.) Now you put these in a balanced binary tree whose in-order traversal gives the sequence of letters in the order they appear in the string. You might now recognize the partial sums problem: You enhance the tree so that nodes contain (letter, distance, sum). The sum is the sum of all distances in the left subtree. (Therefore sum(x)=distance(left(x))+sum(left(x)).) You can now query and update this data structure in logarithmic time. To say that you added n characters to the left of character c you say distance(c)+=n an then go and update sum for all parents of c. To ask what is the index of c you compute sum(c)+sum(parent(c))+sum(parent(parent(c)))+... | What is the most efficient way to keep track of a specific character's index in a string? Take the following string as an example: "The quick brown fox" Right now the q in quick is at index 4 of the string (starting at 0) and the f in fox is at index 16. Now lets say the user enters some more text into this string. "The very quick dark brown fox" Now the q is at index 9 and the f is at index 26. What is the most efficient method of keeping track of the index of the original q in quick and f in fox no matter how many characters are added by the user? Language doesn't matter to me, this is more of a theory question than anything so use whatever language you want just try to keep it to generally popular and current languages. The sample string I gave is short but I'm hoping for a way that can efficiently handle any size string. So updating an array with the offset would work with a short string but will bog down with to many characters. Even though in the example I was looking for the index of unique characters in the string I also want to be able to track the index of the same character in different locations such as the o in brown and the o in fox. So searching is out of the question. I was hoping for the answer to be both time and memory efficient but if I had to choose just one I care more about performance speed. | TITLE:
What is the most efficient way to keep track of a specific character's index in a string?
QUESTION:
Take the following string as an example: "The quick brown fox" Right now the q in quick is at index 4 of the string (starting at 0) and the f in fox is at index 16. Now lets say the user enters some more text into this string. "The very quick dark brown fox" Now the q is at index 9 and the f is at index 26. What is the most efficient method of keeping track of the index of the original q in quick and f in fox no matter how many characters are added by the user? Language doesn't matter to me, this is more of a theory question than anything so use whatever language you want just try to keep it to generally popular and current languages. The sample string I gave is short but I'm hoping for a way that can efficiently handle any size string. So updating an array with the offset would work with a short string but will bog down with to many characters. Even though in the example I was looking for the index of unique characters in the string I also want to be able to track the index of the same character in different locations such as the o in brown and the o in fox. So searching is out of the question. I was hoping for the answer to be both time and memory efficient but if I had to choose just one I care more about performance speed.
ANSWER:
Let's say that you have a string and some of its letters are interesting. To make things easier let's say that the letter at index 0 is always interesting and you never add something before it—a sentinel. Write down pairs of (interesting letter, distance to the previous interesting letter). If the string is "+the very Quick dark brown Fox" and you are interested in q from 'quick' and f from 'fox' then you would write: (+,0), (q,10), (f,17). (The sign + is the sentinel.) Now you put these in a balanced binary tree whose in-order traversal gives the sequence of letters in the order they appear in the string. You might now recognize the partial sums problem: You enhance the tree so that nodes contain (letter, distance, sum). The sum is the sum of all distances in the left subtree. (Therefore sum(x)=distance(left(x))+sum(left(x)).) You can now query and update this data structure in logarithmic time. To say that you added n characters to the left of character c you say distance(c)+=n an then go and update sum for all parents of c. To ask what is the index of c you compute sum(c)+sum(parent(c))+sum(parent(parent(c)))+... | [
"algorithm",
"string",
"optimization"
] | 2 | 2 | 460 | 4 | 0 | 2008-08-30T16:45:44.633000 | 2008-10-07T09:22:39.627000 |
36,127 | 38,474 | Any recommended VC++ settings for better PDB analysis on release builds | Are there any VC++ settings I should know about to generate better PDB files that contain more information? I have a crash dump analysis system in place based on the project crashrpt. Also, my production build server has the source code installed on the D:\, but my development machine has the source code on the C:\. I entered the source path in the VC++ settings, but when looking through the call stack of a crash, it doesn't automatically jump to my source code. I believe if I had my dev machine's source code on the D:\ it would work. | "Are there any VC++ settings I should know about" Make sure you turn off Frame pointer ommision. Larry osterman's blog has the historical details about fpo and the issues it causes with debugging. Symbols are loaded successfully. It shows the callstack, but double clicking on an entry doesn't bring me to the source code. What version of VS are you using? (Or are you using Windbg?)... in VS it should defintely prompt for source the first time if it doesn't find the location. However it also keeps a list of source that was 'not found' so it doesn't ask you for it every time. Sometimes the don't look list is a pain... to get the prompt back up you need to go to solution explorer/solution node/properties/debug properties and edit the file list in the lower pane. Finally you might be using 'stripped symbols'. These are pdb files generated to provide debug info for walking the callstack past FPO, but with source locations stripped out (along with other data). The public symbols for windows OS components are stripped pdbs. For your own code these simply cause pain and are not worth it unless you are providing your pdbs to externals. How would you have one of these horrible stripped pdbs? You might have them if you use "binplace" with the -a command. Good luck! A proper mini dump story is a godsend for production debugging. | Any recommended VC++ settings for better PDB analysis on release builds Are there any VC++ settings I should know about to generate better PDB files that contain more information? I have a crash dump analysis system in place based on the project crashrpt. Also, my production build server has the source code installed on the D:\, but my development machine has the source code on the C:\. I entered the source path in the VC++ settings, but when looking through the call stack of a crash, it doesn't automatically jump to my source code. I believe if I had my dev machine's source code on the D:\ it would work. | TITLE:
Any recommended VC++ settings for better PDB analysis on release builds
QUESTION:
Are there any VC++ settings I should know about to generate better PDB files that contain more information? I have a crash dump analysis system in place based on the project crashrpt. Also, my production build server has the source code installed on the D:\, but my development machine has the source code on the C:\. I entered the source path in the VC++ settings, but when looking through the call stack of a crash, it doesn't automatically jump to my source code. I believe if I had my dev machine's source code on the D:\ it would work.
ANSWER:
"Are there any VC++ settings I should know about" Make sure you turn off Frame pointer ommision. Larry osterman's blog has the historical details about fpo and the issues it causes with debugging. Symbols are loaded successfully. It shows the callstack, but double clicking on an entry doesn't bring me to the source code. What version of VS are you using? (Or are you using Windbg?)... in VS it should defintely prompt for source the first time if it doesn't find the location. However it also keeps a list of source that was 'not found' so it doesn't ask you for it every time. Sometimes the don't look list is a pain... to get the prompt back up you need to go to solution explorer/solution node/properties/debug properties and edit the file list in the lower pane. Finally you might be using 'stripped symbols'. These are pdb files generated to provide debug info for walking the callstack past FPO, but with source locations stripped out (along with other data). The public symbols for windows OS components are stripped pdbs. For your own code these simply cause pain and are not worth it unless you are providing your pdbs to externals. How would you have one of these horrible stripped pdbs? You might have them if you use "binplace" with the -a command. Good luck! A proper mini dump story is a godsend for production debugging. | [
"visual-studio",
"visual-c++",
"pdb-files",
"crashrpt"
] | 12 | 5 | 3,014 | 7 | 0 | 2008-08-30T16:51:03.730000 | 2008-09-01T21:41:59.600000 |
36,129 | 36,167 | What are some real life examples of Design Patterns used in software | I'm reading through head first design patterns at the moment and while the book is excellent I also would like to see how these are actually used in the real world. If you know of a good example of design pattern usage (preferably in a OSS program so we can have a look:) then please list it below. | An ah-ha moment for me for the observer pattern was to realize how closely associated it is with events. Consider a Windows program that needs to acheive loosely communications between two forms. That can easily be accomplished with the observer pattern. The code below shows how Form2 fires an event and any other class registered as an observer get its data. See this link for a great patterns resource: http://sourcemaking.com/design-patterns-and-tips Form1's code: namespace PublishSubscribe { public partial class Form1: Form { Form2 f2 = new Form2();
public Form1() { InitializeComponent();
f2.PublishData += new PublishDataEventHander( DataReceived ); f2.Show(); }
private void DataReceived( object sender, Form2EventArgs e ) { MessageBox.Show( e.OtherData ); } } } Form2's code namespace PublishSubscribe {
public delegate void PublishDataEventHander( object sender, Form2EventArgs e );
public partial class Form2: Form { public event PublishDataEventHander PublishData;
public Form2() { InitializeComponent(); }
private void button1_Click( object sender, EventArgs e ) { PublishData( this, new Form2EventArgs( "data from form2" ) ); } }
public class Form2EventArgs: System.EventArgs { public string OtherData;
public Form2EventArgs( string OtherData ) { this.OtherData = OtherData; } } } | What are some real life examples of Design Patterns used in software I'm reading through head first design patterns at the moment and while the book is excellent I also would like to see how these are actually used in the real world. If you know of a good example of design pattern usage (preferably in a OSS program so we can have a look:) then please list it below. | TITLE:
What are some real life examples of Design Patterns used in software
QUESTION:
I'm reading through head first design patterns at the moment and while the book is excellent I also would like to see how these are actually used in the real world. If you know of a good example of design pattern usage (preferably in a OSS program so we can have a look:) then please list it below.
ANSWER:
An ah-ha moment for me for the observer pattern was to realize how closely associated it is with events. Consider a Windows program that needs to acheive loosely communications between two forms. That can easily be accomplished with the observer pattern. The code below shows how Form2 fires an event and any other class registered as an observer get its data. See this link for a great patterns resource: http://sourcemaking.com/design-patterns-and-tips Form1's code: namespace PublishSubscribe { public partial class Form1: Form { Form2 f2 = new Form2();
public Form1() { InitializeComponent();
f2.PublishData += new PublishDataEventHander( DataReceived ); f2.Show(); }
private void DataReceived( object sender, Form2EventArgs e ) { MessageBox.Show( e.OtherData ); } } } Form2's code namespace PublishSubscribe {
public delegate void PublishDataEventHander( object sender, Form2EventArgs e );
public partial class Form2: Form { public event PublishDataEventHander PublishData;
public Form2() { InitializeComponent(); }
private void button1_Click( object sender, EventArgs e ) { PublishData( this, new Form2EventArgs( "data from form2" ) ); } }
public class Form2EventArgs: System.EventArgs { public string OtherData;
public Form2EventArgs( string OtherData ) { this.OtherData = OtherData; } } } | [
"design-patterns"
] | 7 | 3 | 21,557 | 10 | 0 | 2008-08-30T16:51:19.220000 | 2008-08-30T17:17:25.913000 |
36,139 | 36,156 | How to sort a list of strings? | What is the best way of creating an alphabetically sorted list in Python? | Basic answer: mylist = ["b", "C", "A"] mylist.sort() This modifies your original list (i.e. sorts in-place). To get a sorted copy of the list, without changing the original, use the sorted() function: for x in sorted(mylist): print x However, the examples above are a bit naive, because they don't take locale into account, and perform a case-sensitive sorting. You can take advantage of the optional parameter key to specify custom sorting order (the alternative, using cmp, is a deprecated solution, as it has to be evaluated multiple times - key is only computed once per element). So, to sort according to the current locale, taking language-specific rules into account ( cmp_to_key is a helper function from functools): sorted(mylist, key=cmp_to_key(locale.strcoll)) And finally, if you need, you can specify a custom locale for sorting: import locale locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') # vary depending on your lang/locale assert sorted((u'Ab', u'ad', u'aa'), key=cmp_to_key(locale.strcoll)) == [u'aa', u'Ab', u'ad'] Last note: you will see examples of case-insensitive sorting which use the lower() method - those are incorrect, because they work only for the ASCII subset of characters. Those two are wrong for any non-English data: # this is incorrect! mylist.sort(key=lambda x: x.lower()) # alternative notation, a bit faster, but still wrong mylist.sort(key=str.lower) | How to sort a list of strings? What is the best way of creating an alphabetically sorted list in Python? | TITLE:
How to sort a list of strings?
QUESTION:
What is the best way of creating an alphabetically sorted list in Python?
ANSWER:
Basic answer: mylist = ["b", "C", "A"] mylist.sort() This modifies your original list (i.e. sorts in-place). To get a sorted copy of the list, without changing the original, use the sorted() function: for x in sorted(mylist): print x However, the examples above are a bit naive, because they don't take locale into account, and perform a case-sensitive sorting. You can take advantage of the optional parameter key to specify custom sorting order (the alternative, using cmp, is a deprecated solution, as it has to be evaluated multiple times - key is only computed once per element). So, to sort according to the current locale, taking language-specific rules into account ( cmp_to_key is a helper function from functools): sorted(mylist, key=cmp_to_key(locale.strcoll)) And finally, if you need, you can specify a custom locale for sorting: import locale locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') # vary depending on your lang/locale assert sorted((u'Ab', u'ad', u'aa'), key=cmp_to_key(locale.strcoll)) == [u'aa', u'Ab', u'ad'] Last note: you will see examples of case-insensitive sorting which use the lower() method - those are incorrect, because they work only for the ASCII subset of characters. Those two are wrong for any non-English data: # this is incorrect! mylist.sort(key=lambda x: x.lower()) # alternative notation, a bit faster, but still wrong mylist.sort(key=str.lower) | [
"python",
"string",
"sorting"
] | 493 | 582 | 688,241 | 11 | 0 | 2008-08-30T17:03:09.350000 | 2008-08-30T17:10:12.687000 |
36,152 | 36,165 | How do you unsubscribe from a ubiquity command | I can't seem to find details on how to unsubscribe from ubiquity commands. The command list page only seems to have information about the installed commands and there are no links to deleting them. Am I missing something? | Go to about:ubiquity in Firefox. Under the section "subscribed feeds" there should be an option to unsubscribe to command feeds you no longer desire. Also, if you clear your entire browser history, it will delete all command feeds (this will be fixed by 0.2) | How do you unsubscribe from a ubiquity command I can't seem to find details on how to unsubscribe from ubiquity commands. The command list page only seems to have information about the installed commands and there are no links to deleting them. Am I missing something? | TITLE:
How do you unsubscribe from a ubiquity command
QUESTION:
I can't seem to find details on how to unsubscribe from ubiquity commands. The command list page only seems to have information about the installed commands and there are no links to deleting them. Am I missing something?
ANSWER:
Go to about:ubiquity in Firefox. Under the section "subscribed feeds" there should be an option to unsubscribe to command feeds you no longer desire. Also, if you clear your entire browser history, it will delete all command feeds (this will be fixed by 0.2) | [
"ubiquity"
] | 2 | 2 | 842 | 3 | 0 | 2008-08-30T17:09:16.823000 | 2008-08-30T17:16:39.083000 |
36,182 | 36,397 | How expensive is ST_GeomFromText | In postgis, is the ST_GeomFromText call very expensive? I ask mostly because I have a frequently called query that attempts to find the point that is nearest another point that matches some criteria, and which is also within a certain distance of that other point, and the way I currently wrote it, it's doing the same ST_GeomFromText twice: $findNearIDMatchStmt = $postconn->prepare( "SELECT internalid ". "FROM waypoint ". "WHERE id =? AND ". " category =? AND ". " (b.category in (1, 3) OR type like?) AND ". " ST_DWithin(point, ST_GeomFromText(?,". SRID. " ),". SMALL_EPSILON. ") ". " ORDER BY ST_Distance(point, ST_GeomFromText(?,", SRID. " )) ". " LIMIT 1"); Is there a better way to re-write this? Slightly OT: In the preview screen, all my underscores are being rendered as & # 9 5; - I hope that's not going to show up that way in the post. | I don't believe ST_GeomFromText() is particularly expensive, although in the past I've optimized PostGIS queries by creating a function, declaring a variable and then assigning the result of ST_GeomFromText to the variable. Have you tried checking the execution plan for you query with a variety of different parameters because that should give you a definite idea of which bits of the query are taking the time? I'm guessing most of the execution time will be in the calls to ST_DWithin() and ST_Distance(), although if the id and category columns aren't indexed then it might be doing some interesting table scanning. | How expensive is ST_GeomFromText In postgis, is the ST_GeomFromText call very expensive? I ask mostly because I have a frequently called query that attempts to find the point that is nearest another point that matches some criteria, and which is also within a certain distance of that other point, and the way I currently wrote it, it's doing the same ST_GeomFromText twice: $findNearIDMatchStmt = $postconn->prepare( "SELECT internalid ". "FROM waypoint ". "WHERE id =? AND ". " category =? AND ". " (b.category in (1, 3) OR type like?) AND ". " ST_DWithin(point, ST_GeomFromText(?,". SRID. " ),". SMALL_EPSILON. ") ". " ORDER BY ST_Distance(point, ST_GeomFromText(?,", SRID. " )) ". " LIMIT 1"); Is there a better way to re-write this? Slightly OT: In the preview screen, all my underscores are being rendered as & # 9 5; - I hope that's not going to show up that way in the post. | TITLE:
How expensive is ST_GeomFromText
QUESTION:
In postgis, is the ST_GeomFromText call very expensive? I ask mostly because I have a frequently called query that attempts to find the point that is nearest another point that matches some criteria, and which is also within a certain distance of that other point, and the way I currently wrote it, it's doing the same ST_GeomFromText twice: $findNearIDMatchStmt = $postconn->prepare( "SELECT internalid ". "FROM waypoint ". "WHERE id =? AND ". " category =? AND ". " (b.category in (1, 3) OR type like?) AND ". " ST_DWithin(point, ST_GeomFromText(?,". SRID. " ),". SMALL_EPSILON. ") ". " ORDER BY ST_Distance(point, ST_GeomFromText(?,", SRID. " )) ". " LIMIT 1"); Is there a better way to re-write this? Slightly OT: In the preview screen, all my underscores are being rendered as & # 9 5; - I hope that's not going to show up that way in the post.
ANSWER:
I don't believe ST_GeomFromText() is particularly expensive, although in the past I've optimized PostGIS queries by creating a function, declaring a variable and then assigning the result of ST_GeomFromText to the variable. Have you tried checking the execution plan for you query with a variety of different parameters because that should give you a definite idea of which bits of the query are taking the time? I'm guessing most of the execution time will be in the calls to ST_DWithin() and ST_Distance(), although if the id and category columns aren't indexed then it might be doing some interesting table scanning. | [
"gis",
"postgis"
] | 1 | 1 | 986 | 2 | 0 | 2008-08-30T17:25:40.870000 | 2008-08-30T22:16:10.093000 |
36,183 | 36,191 | Replacing the nth instance of a regex match in Javascript | I'm trying to write a regex function that will identify and replace a single instance of a match within a string without affecting the other instances. For example, I have this string: 12||34||56 I want to replace the second set of pipes with ampersands to get this string: 12||34&&56 The regex function needs to be able to handle x amount of pipes and allow me to replace the nth set of pipes, so I could use the same function to make these replacements: 23||45||45||56||67 -> 23&&45||45||56||67
23||34||98||87 -> 23||34||98&&87 I know that I could just split/replace/concat the string at the pipes, and I also know that I can match on /\|\|/ and iterate through the resulting array, but I'm interested to know if it's possible to write a single expression that can do this. Note that this would be for Javascript, so it's possible to generate a regex at runtime using eval(), but it's not possible to use any Perl-specific regex instructions. | here's something that works: "23||45||45||56||67".replace(/^((?:[0-9]+\|\|){n})([0-9]+)\|\|/,"$1$2&&") where n is the one less than the nth pipe, (of course you don't need that first subexpression if n = 0) And if you'd like a function to do this: function pipe_replace(str,n) { var RE = new RegExp("^((?:[0-9]+\\|\\|){" + (n-1) + "})([0-9]+)\|\|"); return str.replace(RE,"$1$2&&"); } | Replacing the nth instance of a regex match in Javascript I'm trying to write a regex function that will identify and replace a single instance of a match within a string without affecting the other instances. For example, I have this string: 12||34||56 I want to replace the second set of pipes with ampersands to get this string: 12||34&&56 The regex function needs to be able to handle x amount of pipes and allow me to replace the nth set of pipes, so I could use the same function to make these replacements: 23||45||45||56||67 -> 23&&45||45||56||67
23||34||98||87 -> 23||34||98&&87 I know that I could just split/replace/concat the string at the pipes, and I also know that I can match on /\|\|/ and iterate through the resulting array, but I'm interested to know if it's possible to write a single expression that can do this. Note that this would be for Javascript, so it's possible to generate a regex at runtime using eval(), but it's not possible to use any Perl-specific regex instructions. | TITLE:
Replacing the nth instance of a regex match in Javascript
QUESTION:
I'm trying to write a regex function that will identify and replace a single instance of a match within a string without affecting the other instances. For example, I have this string: 12||34||56 I want to replace the second set of pipes with ampersands to get this string: 12||34&&56 The regex function needs to be able to handle x amount of pipes and allow me to replace the nth set of pipes, so I could use the same function to make these replacements: 23||45||45||56||67 -> 23&&45||45||56||67
23||34||98||87 -> 23||34||98&&87 I know that I could just split/replace/concat the string at the pipes, and I also know that I can match on /\|\|/ and iterate through the resulting array, but I'm interested to know if it's possible to write a single expression that can do this. Note that this would be for Javascript, so it's possible to generate a regex at runtime using eval(), but it's not possible to use any Perl-specific regex instructions.
ANSWER:
here's something that works: "23||45||45||56||67".replace(/^((?:[0-9]+\|\|){n})([0-9]+)\|\|/,"$1$2&&") where n is the one less than the nth pipe, (of course you don't need that first subexpression if n = 0) And if you'd like a function to do this: function pipe_replace(str,n) { var RE = new RegExp("^((?:[0-9]+\\|\\|){" + (n-1) + "})([0-9]+)\|\|"); return str.replace(RE,"$1$2&&"); } | [
"javascript",
"regex"
] | 29 | 20 | 17,575 | 4 | 0 | 2008-08-30T17:26:09.230000 | 2008-08-30T17:40:39.960000 |
36,186 | 619,713 | Best Versioning Tools to use for Photoshop/Illustrator and related binary files? | I previously asked about Version Cue 3 vs Subversion. I think this is a better question and someone suggested http://www.gridironsoftware.com/Flow/ I hope this question will allow others to join in and suggest other tools or give specific recommendation to using Version Que versus other tools. | Take a look at this article comparing Subversion, Mercurial, Git and Bazaar for managing the files in a home directory, including image files and large Photoshop files that are being edited and versioned. EDIT: The link is dead and I can't find the article, however the information in the article is now severely outdated anyway. Today I would strongly recommend using Git-LFS (Large File System), with the file locking mechanism that was added in 2017, I believe. This is the solution I currently use, as it solves both the problem of needed to lock binary files, and avoids the inefficiencies of git when it comes to storing large files - which was one of the main points of that article. | Best Versioning Tools to use for Photoshop/Illustrator and related binary files? I previously asked about Version Cue 3 vs Subversion. I think this is a better question and someone suggested http://www.gridironsoftware.com/Flow/ I hope this question will allow others to join in and suggest other tools or give specific recommendation to using Version Que versus other tools. | TITLE:
Best Versioning Tools to use for Photoshop/Illustrator and related binary files?
QUESTION:
I previously asked about Version Cue 3 vs Subversion. I think this is a better question and someone suggested http://www.gridironsoftware.com/Flow/ I hope this question will allow others to join in and suggest other tools or give specific recommendation to using Version Que versus other tools.
ANSWER:
Take a look at this article comparing Subversion, Mercurial, Git and Bazaar for managing the files in a home directory, including image files and large Photoshop files that are being edited and versioned. EDIT: The link is dead and I can't find the article, however the information in the article is now severely outdated anyway. Today I would strongly recommend using Git-LFS (Large File System), with the file locking mechanism that was added in 2017, I believe. This is the solution I currently use, as it solves both the problem of needed to lock binary files, and avoids the inefficiencies of git when it comes to storing large files - which was one of the main points of that article. | [
"versioning",
"photoshop"
] | 10 | 4 | 18,680 | 5 | 0 | 2008-08-30T17:31:20.030000 | 2009-03-06T17:33:47.833000 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.