Search Results

Search found 24117 results on 965 pages for 'write'.

Page 24/965 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Why not write all tests at once when doing TDD? [closed]

    - by RichK
    Possible Duplicate: Why not write all tests at once when doing TDD? The Red - Green - Refactor cycle for TDD is well established and accepted. We write one failing unit test and make it pass as simply as possible. What are the benefits to this approach over writing many failing unit tests for a class and make them all pass in one go. The test suite still protects you against writing incorrect code or making mistakes in the refactoring stage, and code coverage should be just as high, so what's the harm? Sometimes it's easier to write all the tests first as a form of 'brain dump' to quickly write down all the expected behavior in one go.

    Read the article

  • Fastest way to write large STL vector to file using STL

    - by ljubak
    I have a large vector (10^9 elements) of chars, and I was wondering what is the fastest way to write such vector to a file. So far I've been using next code: vector<char> vs; // ... Fill vector with data ofstream outfile("nanocube.txt", ios::out | ios::binary); ostream_iterator<char> oi(outfile, '\0'); copy(vs.begin(), vs.end(), oi); For this code it takes approximately two minutes to write all data to file. The actual question is: "Can I make it faster using STL and how"?

    Read the article

  • Read and write into a file using VBScript

    - by Maddy
    How can we read and write some string into a text file using VBScript? I mean I have a text file which is already present so when I use this code below:- Set fso = CreateObject("Scripting.FileSystemObject" ) Set file = fso.OpenTextFile("C:\New\maddy.txt",1,1) This opens the file only for reading but I am unable to write anything and when I use this code:- Set fso = CreateObject("Scripting.FileSystemObject" ) Set file = fso.OpenTextFile("C:\New\maddy.txt",2,1) I can just use this file for writing but unable to read anything. Is there anyway by which we can open the file for reading and writing by just calling the OpenTextFile method only once. I am really new to VBScript. I am only familiar with C concepts. Is there any link to really get me started with VBScript? I guess I need to have a good knowledge of the objects and properties concepts.

    Read the article

  • write error: Broken pipe

    - by Fahim
    Hi, I have to run a tool on around 300 directories. Each run take around 1 minute to 30 minute or even more than that. So, I wrote a python script having a loop to run the tool on all directories one after another. my python script has code something like: for directory in directories: os.popen('runtool_exec ' + directory) But when I run the python script I get the following error messages repeatedly: .. tail: write error: Broken pipe date: write error: Broken pipe .. All I do is login on a remote server using ssh where the tool, python script, and subject directories are kept. When I individually run the tool from command prompt using command like: runtool_exec directory it works fine. "broken pipe" error is coming only when I run using the python script. Any idea, workaround? Please suggest. Thanks. Fahim

    Read the article

  • Why does x86 WiX installer on Vista x64 not write keys to WOW6432Node in the registry

    - by Ryan Conrad
    I have an installer that writes to HKLM\Software\DroidExplorer\InstallPath. On any x86 machine it writes just fine to the expected location, on Windows XP x64 and Windows 7 x64 it also writes to the expected location, which is actually HKLM\Software\WOW6432Node\DroidExplorer\InstallPath. Later on during the install, my bootstrapper, which is also x86, attempts to read the value. On all x86 Windows machines it is successful, and on Windows XP x64 and Windows 7 x64, but Windows Vista x64 is unable to locate the key. If I look in the registry, it doesn't actually write it to WOW6432Node on Vista, it writes it to Software\DroidExplorer\InstallPath If I do not forcefully tell the installer to write to WOW6432Node, it writes the value to Software\DroidExplorer\InstallPath, but the bootstrapper still trys to look in WOW6432Node because of the Registry Reflection. This is on all x64 systems. Why is Vista x64 the only one I have this issue with? Is there a way around this?

    Read the article

  • CLOB WRITE WITH OO4O

    - by Maagne Larsen
    I get the error : OIP-04908: This operation is not permitted on a Null LOB when Set MyClOB_0 = lOraDynaset_0.Fields("FILE_BODY").Value lOraDynaset_0.Edit amount_written = MyClOB_0.Write(buffer, chunksize, ORALOB_FIRST_PIECE)

    Read the article

  • Write binary stream to browser using PHP

    - by Dave Jarvis
    Background Trying to stream a PDF report written using iReport through PHP to the browser. The general problem is: how do you write binary data to the browser using PHP? Working Code The following code does the job, but (for many reasons) it is not as efficient as it should be (the code writes a file then sends the file contents the browser). // Load the MySQL database driver. // java( 'java.lang.Class' )->forName( 'com.mysql.jdbc.Driver' ); // Attempt a database connection. // $conn = java( 'java.sql.DriverManager' )->getConnection( "jdbc:mysql://localhost:3306/climate?user=$user&password=$password" ); // Extract parameters. // $params = new java('java.util.HashMap'); $params->put('DistrictCode', '101'); $params->put('StationCode', '0066'); $params->put('CategoryCode', '010'); // Use the fill manager to produce the report. // $fm = java('net.sf.jasperreports.engine.JasperFillManager'); $pm = $fm->fillReport($report, $params, $conn); header('Cache-Control: no-cache private'); header('Content-Description: File Transfer'); header('Content-Disposition: attachment, filename=climate-report.pdf'); header('Content-Type: application/pdf'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . strlen( $result ) ); $path = realpath( "." ) . "/output.pdf"; $em = java('net.sf.jasperreports.engine.JasperExportManager'); $result = $em->exportReportToPdfFile($pm,$path); readfile( $path ); $conn->close(); Non-working Code To remove the slight redundancy (i.e., write directly to the browser), the following code looks like it should work, but it does not: $em = java('net.sf.jasperreports.engine.JasperExportManager'); $result = $em->exportReportToPdf($pm); header('Content-Length: ' . strlen( $result ) ); echo $result; Content is sent to the browser, but the file is corrupt (it begins with the PDF header) and cannot be read by any PDF reader. Question How can I take out the middle step of writing to the file and write directly to the browser so that the PDF is not corrupted? Thank you!

    Read the article

  • Code to read & write in XML

    - by user2954088
    I am trying to write code to read and write the XML but I am facing some errors, Could please someone provide the sample code to read XML in grid and can update/insert data from grid which will be saved in following sample xml file. Sample XML file: I am facing the below exception: The assembly with display name '...XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly '.....XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

    Read the article

  • How to write software for my touchpad?

    - by Nona Urbiz
    I have some ideas for improvements on my touchpad, ranging from the run of the mill scroll horizontally at the bottom, tapzones for right click, to more complicated ones. But I have no idea where to get started? I'm working on Windows 7 Home Premium, its an Asus laptop, and I have none of these options natively available to me. Regardless, I want to write something that anyone can use. Where would I start? (it'd be nice to write in c++? is that possible? what are the requirements here? what language would be recommended?)

    Read the article

  • windows I/O manager - IRP's classification in read-like and write-like

    - by clyfe
    I am writing a windows filesystem minifilter driver that must fail IRP's in a preoperation callback. How can I find out from the callback parameters if the operation is read-like ( only reads data ) or it's write-like ( modifies data on the disk - write, delete etc ) ? I'm thinking on: Data->Iopb->TargetFileObject->ReadAccess Data->Iopb->TargetFileObject->WriteAccess But I'm not sure, I think thees are available only in postoperation callback. The documentation is really cumbersome. Code sample: FLT_PREOP_CALLBACK_STATUS Fail ( __inout PFLT_CALLBACK_DATA Data, __in PCFLT_RELATED_OBJECTS FltObjects, __deref_out_opt PVOID *CompletionContext ) { FLT_PREOP_CALLBACK_STATUS status = FLT_PREOP_SUCCESS_NO_CALLBACK; if ( IS WRITE_LIKE(Data, FltObjects) ) { // ??? HOW DO I FIND OUT???? if( FLT_IS_FASTIO_OPERATION(Data) ){ status = FLT_PREOP_DISALLOW_FASTIO; } else { status = FLT_PREOP_COMPLETE; } Data->IoStatus.Status = STATUS_ACCESS_DENIED; Data->IoStatus.Information = 0; return status; } return status; }

    Read the article

  • How to write a Custom DesignerSerializer for an class used by a Activity (WF)

    - by Stefan Steinegger
    I have a type which is used in a WF activity. It should be serialized. It doesn't work out of the box, most probably because of the private setters in that type. I'm not sure if this is the correct way, but I tried to write my own serializer and declared it on my class. [DesignerSerializer( typeof(FooDesignerSerializer), // my custom serializer typeof(WorkflowMarkupSerializer))] public class Foo { public Foo(int value, string name { // ... } public int Value { get; private set; } public string Name { get; private set; } } Is this the easiest way to get it serialized? How do I write this serializer? That's what I got so far: public class FooDesignerSerializer : WorkflowMarkupSerializer { protected override string SerializeToString( WorkflowMarkupSerializationManager serializationManager, object value) { // how to create a valid / XOML-like string? } }

    Read the article

  • Write Scheme data structures so they can be eval-d back in, or alternative

    - by Jesse Millikan
    I'm writing an application (A juggling pattern animator) in PLT Scheme that accepts Scheme expressions as values for some fields. I'm attempting to write a small text editor that will let me "explode" expressions into expressions that can still be eval'd but contain the data as literals for manual tweaking. For example, (4hss->sexp "747") is a function call that generates a legitimate pattern. If I eval and print that, it becomes (((7 3) - - -) (- - (4 2) -) (- (7 2) - -) (- - - (7 1)) ((4 0) - - -) (- - (7 0) -) (- (7 2) - -) (- - - (4 3)) ((7 3) - - -) (- - (7 0) -) (- (4 1) - -) (- - - (7 1))) which can be "read" as a string, but will not "eval" the same as the function. For this statement, of course, what I need would be as simple as (quote (((7 3... but other examples are non-trivial. This one, for example, contains structs which print as vectors: pair-of-jugglers ; --> (#(struct:hand #(struct:position -0.35 2.0 1.0) #(struct:position -0.6 2.05 1.1) 1.832595714594046) #(struct:hand #(struct:position 0.35 2.0 1.0) #(struct:position 0.6 2.0500000000000003 1.1) 1.308996938995747) #(struct:hand #(struct:position 0.35 -2.0 1.0) #(struct:position 0.6 -2.05 1.1) -1.3089969389957472) #(struct:hand #(struct:position -0.35 -2.0 1.0) #(struct:position -0.6 -2.05 1.1) -1.8325957145940461)) I've thought of at least three possible solutions, none of which I like very much. Solution A is to write a recursive eval-able output function myself for a reasonably large subset of the values that I might be using. There (probably...) won't be any circular references by the nature of the data structures used, so that wouldn't be such a long job. The output would end up looking like `(((3 0) (... ; ex 1 `(,(make-hand (make-position ... ; ex 2 Or even worse if I could't figure out how to do it properly with quasiquoting. Solution B would be to write out everything as (read (open-input-string "(big-long-s-expression)")) which, technically, solves the problem I'm bringing up but is... ugly. Solution C might be a different approach of giving up eval and using only read for parsing input, or an uglier approach where the s-expression is used as directly data if eval fails, but those both seem unpleasant compared to using scheme values directly. Undiscovered Solution D would be a PLT Scheme option, function or library I haven't located that would match Solution A. Help me out before I start having bad recursion dreams again.

    Read the article

  • Mercurial clone operation works, but I don't have write access

    - by normalocity
    Somewhere I did something silly. I was deploying my Rails app via cloning the Mercurial repo down onto my Ubuntu server. It worked the first time, and then...well, I made a small change on my dev machine, pushed the changes to the repo, and then deleted the copy on the Ubuntu server and re-cloned from the repo. The clone operation (the second, and third, and 'n' times) works without error, but I don't have write access to the files that were cloned. When I try to startup my mongrel - it can't create the /tmp folder, and because of no write access, fails to start the Rails app.

    Read the article

  • How do you write byte[] array using log4.net

    - by like.no.other
    Hi, I have a byte[] with some data in it, I would like to write this byte array AS-IS to the log file using log4.net. The problems that i am facing is that There are no overload for byte[] in TextWriter, so even implementing an IObjectRenderer is of no use. I dont have access to the underlying Stream object of Log4.net Also tried converting byte[] into char[] still when i write it, it adds an extra byte. Is this even possible with Log4.net. Thanx in Advance.

    Read the article

  • Change write-host output color based on foreach if elseif outcome in Powershell

    - by Emo
    I'm trying to change the color of write-host output based on the lastrunoutcome property of SQL Server jobs in Powershell....as in...if a job was successfull, the output of lastrunoutcome is "Success" in green....if failed, then "Failed" in red. I have the script working to get the desired job status...I just don't know how to change the colors. Here's what I have so far: # Check for failed SQL jobs on multiple servers [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null foreach ($svr in get-content "C:\serverlist2.txt") { $a = get-date $BegDate = (Get-Date $a.AddDays(-1) -f d) + " 12:00:00 AM" $BegDateTrans = [system.datetime]$BegDate write-host $svr $srv=New-Object "Microsoft.SqlServer.Management.Smo.Server" "$svr" $srv.jobserver.jobs | where-object {$_.lastrundate -ge $BegDateTrans -and $_.Name -notlike "????????-????-????-????-????????????"} | format-table name,lastrunoutcome,lastrundate -autosize foreach ($_.lastrunoutcome in $srv.jobserver.jobs) { if ($_.lastrunoutcome = 0) { -forgroundcolor red } else {} } } This seems to be the closest I've gotten...but it's giving me an error of ""LastRunOutcome" is a ReadOnly property." Any help would be greatly appreciated! Thanks! Emo

    Read the article

  • How do I handle partial write completions from overlapped I/O using I/O Completion Ports

    - by Poni
    On Windows I/O completion ports, say I do this: void function() { WSASend("1111"); // A WSASend("2222"); // B WSASend("3333"); // C } If I got a "write-complete" that says 3 bytes of WSASend() A were sent, is it possible that right after that I'll get a "write-complete" that tells me that some or all of B & C were sent, or will TCP will hold them until I re-issue a WSASend() call with the rest of A's data? Or will TCP complete it automatically?

    Read the article

  • C#: Check if administrator has write access to a file

    - by Bilal Aslam
    The Problem: I need to check if a user (local user or domain user, either one is possible) has write access to a file (if you're curious, %windir%\system32\inetsrv\applicationHost.config. This file is protected by Windows and you need to be an administrator to write to it.) My Solution: The general construct is: using (Impersonator impersonator = new Impersonator(domain, username, password)) { try { using (FileStream fs = File.OpenWrite(appHostConfigPath)) { return true; } catch { return false; } } As you can imagine, the Impersonator class is an IDisposible which uses native interop to call LogonUser. Nothing too creative, and it works. Where I am stuck: On Windows OSs with UAC enabled, this function always return false even if the user specified by username is an administrator. Even though my program is running elevated as an administrator, I suspect what's happening is that the impersonated code is running as a limited administrator. Hence, the method is returning false. I don't have any creative solutions to this. Can anyone help?

    Read the article

  • I get error when trying to write response stream to a file

    - by MemphisDeveloper
    I am trying to test a rest webservice but when I do a post and try to retreive the save the response stream to a file I get an exception saying "Stream was not readable." What am I doing wrong? Public Sub PostAndRead() Dim flReader As FileStream = New FileStream("~\testRequest.xml", FileMode.Open, FileAccess.Read) Dim flWriter As FileStream = New FileStream("~\testResponse.xml", FileMode.Create, FileAccess.Write) Dim address As Uri = New Uri(restAddress) Dim req As HttpWebRequest = DirectCast(WebRequest.Create(address), HttpWebRequest) req.Method = "POST" req.ContentLength = flReader.Length req.AllowWriteStreamBuffering = True Dim reqStream As Stream = req.GetRequestStream() ' Get data from upload file to inData Dim inData(flReader.Length) As Byte flReader.Read(inData, 0, flReader.Length) ' put data into request stream reqStream.Write(inData, 0, flReader.Length) flReader.Close() reqStream.Close() ' Post Response req.GetResponse() ' Save results in a file Copy(req.GetRequestStream(), flWriter) End Sub

    Read the article

  • How can I write a power function myself?

    - by Koning WWWWWWWWWWWWWWWWWWWWWWW
    Since I was 12, I was always wondering how I can make a function which calculates the power (e.g. 23) myself. In most languages these are included in the standard library, mostly as pow(double x, double y), but how can I write it myself? I was thinking about for loops, but it think my brain got in a loop (when I wanted to do a power with a non-integer exponent, like 54.5 or negatives 2-21) and I went crazy ;) So, how can I write a function which calculates the power of a real number? Thanks

    Read the article

  • Write large PDFs with Java sequentially

    - by Benjamin Muschko
    I am looking for a Java library that let's you write large PDFs sequentially with a minimum amount of memory. Most of the libraries I had a look at has to build up the document in memory first before you can actually write it. The problem I have to deal with are OutOfMemoryErrors. It would be great if I could flush the writer programmatically whenever needed e.g. for each page. Does anyone have any recommendations? I need something with a license along the lines of the LGPL (so not the GPL or the Affero GPL that iText uses).

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >