Sunday, April 3, 2011

JDBC DAO - any good reference implementation?

Can anyone point me to a well written DAO using JDBC, that covers all the exceptions a DAO should handle.

I looked at some samples at java.sun.com, their blue prints but there is a lot of theory and less code.

Looking through Spring DAO source code will be enlightening but that's way too complicated for me.

From stackoverflow

What is disabling my edit-and-continue in vb10 vs2010?

I've been using the vs2010 beta but I can't seem to get edit and continue to work.

  • Compile -> Advanced Options -> Target platform is set to x86 (Compile -> Platform is disabled and set to Active (Any Cpu)?).
  • Options -> Debugging -> Edit-and-continue is checked but grayed out. Presumably for the same reason I can't debug.
  • Options -> Historical Debugging is set to Events Only. Disabling it doesn't help.
  • I get no warnings when trying to modify files while debugging, they're just read-only (shows a lock icon in tab).

What are some other options that might be disabling edit-and-continue?

From stackoverflow
  • I've got the same thing under VS2010 - think it's a bug in VS when targeting anything other than framework 4.0 see here

DataRelation Equivalent in Subsonic 3

I have some code that returns data from a self referencing table (ID,ParentID) into a DataSet. It then adds a DataRelation to the DataSet and writes the DataSet to XML. This write the XML as the expected heirarchy.

How do I do this in Subsonic?

From stackoverflow
  • Why not continue to use the same code? Read the table using subsonic if you like, put it into a data set. There is no feature in subsonic to write xml for you.

what is the minimum access level on a sql server the asp.net membership need?

for security reason, what is the minimum access level the asp.net membership user could have?

From stackoverflow

How to save text-to-speech as a wav with Microsoft SAPI?

Hi,

I think what I am about to want might be easy for you,so I decided to ask it to you,

Fist I need to turn a text into speech and then save it as wav file.

Could you help me ?

Thanks.

From stackoverflow
  • This is from a few moments' play, so caveat emptor. Worked well for me. I did notice that SpFileStream (which doesn't implement IDisposable, thus the try/finally) prefers absolute paths to relative. C#.

       SpFileStream fs = null;
        try
        {
            SpVoice voice = new SpVoice();
            fs = new SpFileStream();
            fs.Open(@"c:\hello.wav", SpeechStreamFileMode.SSFMCreateForWrite, false);
            voice.AudioOutputStream = fs;
            voice.Speak("Hello world.", SpeechVoiceSpeakFlags.SVSFDefault);
        }
        finally
        {
            if (fs != null)
            {
             fs.Close();
            }
        }
    
    Braveyard : Thanks for you effort.
  • The following C# code uses the System.Speech namespace in the .Net framework. It is necessary to reference the namespace before using it, because it is not automatically referenced by Visual Studio.

            SpeechSynthesizer ss = new SpeechSynthesizer();
            ss.Volume = 100;
            ss.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
            ss.SetOutputToWaveFile(@"C:\MyAudioFile.wav");
            ss.Speak("Hello World");
    

    I hope this is relevant and helpful.

    Braveyard : Hi, before that I need to import some dll, because System.Speech is not available in my project even though I added by using "using System.Speech".
    Michael Petrotta : @Mackenzie: this is a better answer than mine, as it uses .net native classes rather than mucking around with COM.
    Michael Petrotta : @atarikg: Reference the System.Speech assembly.
    Braveyard : Hi, Thanks for every thing, I handled the latest question of mine and it works charmingly right now.
  • And as I've found for how to change output format, we code something like this :

    SpeechAudioFormatInfo info = new SpeechAudioFormatInfo(6, AudioBitsPerSample.Sixteen, AudioChannel.Mono);
    
    //Same code comes here 
    
    ss.SetOutputToWaveFile(@"C:\MyAudioFile.wav",info);
    

    That's pretty easy and comprehensible.

    Cool .net

Batch processing in Scala

I have a number of runnable programs written in Java that I'd like to set into one class that would run those one after another in Scala. So for example I have classes: RunMe with arguments "A", "B", "C" WorkbookLoader with arguments "c:\workbooks\", "c:\sourceFile.bin" and "c:\targetFile.bin"

i just need those to call one after another.

Greatly appreciate for giving me an answer in advance.

Sincerely,

Roman

From stackoverflow
  • You have to use Java's Runtime#exec method, just like in Java. See the javadoc here.

Thursday, March 31, 2011

PHPExcel: scientific notation of double/float

The problem is the following: We are creating an instance of a class testObject and fill a var with a double.

A class TestExcel extends from PhpExcel and when submitting the object testObject into the constructor we get a scientific notation of the var when we do a var_dump.

Can anyone help us out. My colleagues and I don't understand how it is possible that the content of an instance can be changed by extending the phpExcel class.

When we don't do the extension, the var_dump returns the correct notation. -- 200000 When doing the extension we get the scientific notation -- 2.0E+5

// instance of the testObject

$number = new testObject();
$number->setNumber((double)200000);

// contruct testExcelClass
$excel = new TestExcel($number);


// Class TestObject      
class testObject {

      private $number;

      public function setNumber($number){
          $this->number = $number;
      }

      public function getNumber(){
          return $this->number;
      }

}

// class test excell extends from phpexcel (http://www.codeplex.com/PHPExcel) 
class TestExcel extends PHPExcel  {

    private $number;

    public function __construct($number){
      parent::__construct();

      $this->number = $number;
      print_r($this->number); exit();

    }

}
From stackoverflow
  • you should probably set formatting of the cell to have the desired number format. i am not sure about the exact function, check the docs.

  • it seemed to be a problem in PHP 5.2.6 that displayed the wrong notation.

    php 5.2.8 solved this bug.