Search Results

Search found 27946 results on 1118 pages for 'output buffer empty'.

Page 156/1118 | < Previous Page | 152 153 154 155 156 157 158 159 160 161 162 163  | Next Page >

  • R: How to separate character output in a loop?

    - by John
    I'm blanking on the best way to paste a list of strings together to go into an SQL statement... I'm having trouble with the separator bar | printing at the beginning when I don't want it to: foo = "blah" paste_all_together = NULL for (n in 1:4) { paste_together = paste(foo ,sep = "") paste_all_together = paste(paste_all_together, paste_together, sep = "|") } > paste_all_together [1] "|blah|blah|blah|blah" I just want it to print out "blah|blah|blah|blah". Do I need a nested loop, or is there a better itterator in R for doing this? Or perhaps a better way to input SQL statements?

    Read the article

  • SQL JOIN with two or more tables as output - most efficient way?

    - by littlegreen
    I have an SQL query that executes a LEFT JOIN on another table, then outputs all results that could be coupled into a designated table. I then have a second SQL query that executes the LEFT JOIN again, then outputs the results that could not be coupled to a designated table. In code, this is something like: INSERT INTO coupledrecords SELECT b.col1, b.col2... s.col1, s.col2... FROM bigtable AS b LEFT JOIN smallertable AS s ON criterium WHERE s.col1 IS NOT NULL INSERT INTO notcoupledrecords SELECT b.col1, b.col2... bigtable AS b LEFT JOIN smallertable AS s ON criterium WHERE s.col1 IS NULL My question: I now have to execute the JOIN two times, in order to achieve what I want. I have a feeling that this is twice as slow as it could be. Is this true, and if yes, is there a way to do it more efficiently?

    Read the article

  • How can I change the color of build output in a shell window?

    - by Tim Gradwell
    I have a build process which runs from a batch file. It produces a large volume of text. Sometimes it prints the word "Error" or "Warning" followed by a message. The errors and warnings are getting lost among a sea of text. Can I highlight those words in a different color, maybe in a dos window, or a cygwin shell window, possibly by piping them through some string manipulation program before posting them to the screen? Thanks.

    Read the article

  • Can I avoid a threaded UDP socket in Pyton dropping data?

    - by 666craig
    First off, I'm new to Python and learning on the job, so be gentle! I'm trying to write a threaded Python app for Windows that reads data from a UDP socket (thread-1), writes it to file (thread-2), and displays the live data (thread-3) to a widget (gtk.Image using a gtk.gdk.pixbuf). I'm using queues for communicating data between threads. My problem is that if I start only threads 1 and 3 (so skip the file writing for now), it seems that I lose some data after the first few samples. After this drop it looks fine. Even by letting thread 1 complete before running thread 3, this apparent drop is still there. Apologies for the length of code snippet (I've removed the thread that writes to file), but I felt removing code would just prompt questions. Hope someone can shed some light :-) import socket import threading import Queue import numpy import gtk gtk.gdk.threads_init() import gtk.glade import pygtk class readFromUDPSocket(threading.Thread): def __init__(self, socketUDP, readDataQueue, packetSize, numScans): threading.Thread.__init__(self) self.socketUDP = socketUDP self.readDataQueue = readDataQueue self.packetSize = packetSize self.numScans = numScans def run(self): for scan in range(1, self.numScans + 1): buffer = self.socketUDP.recv(self.packetSize) self.readDataQueue.put(buffer) self.socketUDP.close() print 'myServer finished!' class displayWithGTK(threading.Thread): def __init__(self, displayDataQueue, image, viewArea): threading.Thread.__init__(self) self.displayDataQueue = displayDataQueue self.image = image self.viewWidth = viewArea[0] self.viewHeight = viewArea[1] self.displayData = numpy.zeros((self.viewHeight, self.viewWidth, 3), dtype=numpy.uint16) def run(self): scan = 0 try: while True: if not scan % self.viewWidth: scan = 0 buffer = self.displayDataQueue.get(timeout=0.1) self.displayData[:, scan, 0] = numpy.fromstring(buffer, dtype=numpy.uint16) self.displayData[:, scan, 1] = numpy.fromstring(buffer, dtype=numpy.uint16) self.displayData[:, scan, 2] = numpy.fromstring(buffer, dtype=numpy.uint16) gtk.gdk.threads_enter() self.myPixbuf = gtk.gdk.pixbuf_new_from_data(self.displayData.tostring(), gtk.gdk.COLORSPACE_RGB, False, 8, self.viewWidth, self.viewHeight, self.viewWidth * 3) self.image.set_from_pixbuf(self.myPixbuf) self.image.show() gtk.gdk.threads_leave() scan += 1 except Queue.Empty: print 'myDisplay finished!' pass def quitGUI(obj): print 'Currently active threads: %s' % threading.enumerate() gtk.main_quit() if __name__ == '__main__': # Create socket (IPv4 protocol, datagram (UDP)) and bind to address socketUDP = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) host = '192.168.1.5' port = 1024 socketUDP.bind((host, port)) # Data parameters samplesPerScan = 256 packetsPerSecond = 1200 packetSize = 512 duration = 1 # For now, set a fixed duration to log data numScans = int(packetsPerSecond * duration) # Create array to store data data = numpy.zeros((samplesPerScan, numScans), dtype=numpy.uint16) # Create queue for displaying from readDataQueue = Queue.Queue(numScans) # Build GUI from Glade XML file builder = gtk.Builder() builder.add_from_file('GroundVue.glade') window = builder.get_object('mainwindow') window.connect('destroy', quitGUI) view = builder.get_object('viewport') image = gtk.Image() view.add(image) viewArea = (1200, samplesPerScan) # Instantiate & start threads myServer = readFromUDPSocket(socketUDP, readDataQueue, packetSize, numScans) myDisplay = displayWithGTK(readDataQueue, image, viewArea) myServer.start() myDisplay.start() gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave() print 'gtk.main finished!'

    Read the article

  • C read X bytes from a file, padding if needed

    - by Hunter McMillen
    I am trying to read in an input file 64 bits at a time, then do some calculations on those 64 bits, the problem is I need to convert the ascii text to hexadecimal characters. I have searched around but none of the answers posted seem to work for my situation. Here is what I have: int main(int argc, int * argv) { char buffer[9]; FILE *f; unsigned long long test; if(f = fopen("input2.txt", "r")) { while( fread(buffer, 8, 1, f) != 0) //while not EOF read 8 bytes at a time { buffer[8] = '\0'; test = strtoull(buffer, NULL, 16); //interpret as hex printf("%llu\n", test); printf("%s\n", buffer); } fclose(f); } } For an input like this: "testing string to hex conversion" I get results like this: 0 testing 0 string t 0 o hex co 0 nversion Where I would expect: 74 65 73 74 69 6e 67 20 <- "testing" in hex testing 73 74 72 69 6e 67 20 74 <- "string t" in hex string t 6f 20 68 65 78 20 63 6f <- "o hex co" in hex o hex co 6e 76 65 72 73 69 6f 6e <- "nversion" in hex nversion Can anyone see where I misstepped?

    Read the article

  • Jquery ajax get - how to output data based on condition?

    - by arunas_t
    Hello, there, I have a such piece of code: $("#choose").change(function(){ $.get("get_results.php", {name: $("#choose").val()}, function(data){ if(data !== ""){ $("#results").html(data); }else{ $("#results").html('<strong>Sorry, no records.</strong>'); } }); }); Now the problem is that the first condition ( if(data !== "") ) is always evaluated correctly and executed, but the else clause ('Sorry, no records') never shows up. Can anyone spot the error? Data passed for the else clause is specifically "". Thank You.

    Read the article

  • Java: Is it possible to take a GUI Panel and output it into a picture?

    - by user369748
    So I have this chart that's a little special. Kind of like an XY plot of points but my boss wanted to look like a bunch of boxes rather than dots connected by lines. And I basically made a chart using gridlayout and a whole bunch of cells that I'll be colouring in black or white depending on the data. Now he sorta wants it to be outputted to a image file. Is there any way to save a Panel into a picture? He wants to display not only the data but also save a visual representation of the data into an image file.

    Read the article

  • Beginnerquestion: How to count amount of each number drawn in a Lottery and output it in a list?

    - by elementz
    I am writing this little Lottery application. Now the plan is, to count how often each number has been drawn during each iteration of the Lottery, and store this somewhere. My guess is that I would need to use a HashMap, that has 6 keys and increments the value by one everytime the respective keys number is drawn. But how would I accomplish this? My code so far: public void numberCreator() { // creating and initializing a Random generator Random rand = new Random(); // A HashMap to store the numbers picked. HashMap hashMap = new HashMap(); // A TreeMap to sort the numbers picked. TreeMap treeMap = new TreeMap(); // creating an ArrayList which will store the pool of availbale Numbers List<Integer>numPool = new ArrayList<Integer>(); for (int i=1; i<50; i++){ // add the available Numbers to the pool numPool.add(i); hashMap.put(nums[i], 0); } // array to store the lotto numbers int [] nums = new int [6]; for (int i =0; i < nums.length; i++){ int numPoolIndex = rand.nextInt(numPool.size()); nums[i] = numPool.get(numPoolIndex); // check how often a number has been called and store the new amount in the Map int counter = hashMap.get numPool.remove(numPoolIndex); } System.out.println(Arrays.toString(nums)); } Maybe someone can tell me if I have the right idea, or even how I would implement the map properly?

    Read the article

  • Why are some programs writing on stderr instead of stdout their output?

    - by Zagorax
    I've recently added to my .bashrc file an ssh-add command. I found that ssh-add $HOME/.ssh/id_rsa_github > /dev/null results on a message "identity added and something else" every time I open a shell. While ssh-add $HOME/.ssh/id_rsa_github > /dev/null 2>&1 did the trick and my shell is now 'clean'. Reading on internet, I found that other command do it, (for example time). Could you please explain why it's done?

    Read the article

  • CSS: How to make a Div of text underneath another Div selectable?

    - by jesse
    Hi, I have a few empty Divs on a page that are basically empty boxes to help me position some stuff to make a "liquid" website. Now I've got content underneath these Divs but I can't highlight/click on the links because these empty Divs are blocking it. I've got a reason I need to have the empty Divs to be on the top layer so I need a way to "click through" these Divs. What can I do? Thanks.

    Read the article

  • Is Memory increase create difference in output or behavior of java application?

    - by Nitz
    Hey Guys I have created one java-swing application. The application runs perfectly runs perfect on my pc. But it doesn't run perfectly on client pc. I had increase my Virtual Memory, earlier on my pc. So my question is.. Is changing memory limit, effect or change application behavior? Is there anything that change the behavior of java application? bcz same application runs perfectly on my pc and same application does not running perfectly on client pc? and there is no problem in code, i have checked three times.

    Read the article

  • Can I get a patch-compatible output from git-diff?

    - by Malvolio
    I am doing something very simple wrong. I'm trying to prepare an ordinary patch file, so I can reapply some changes: $ git diff > before $ git diff something_here > save.patch $ git checkout . $ patch < save.patch $ git diff > after $ diff before after $ With something_here blank it almost works, but the file names aren't right. I think I'm just I'm missing some option. In real life, I am going to do a merge after the checkout, so the patch might fail there, but you see what I'm getting at.

    Read the article

  • Error while trying to reverse a char array

    - by mpminnich
    Hi, I'm trying to get better at C++ (I know a little). I'm working on character arrays. I found an exercise where the objective is to reverse a character array (after I convert it from an integer). I'm getting the following error (using VS2005): Run-Time Check Failure #2 - Stack around the variable 'revBuffer' was corrupted. When I step through the code, I notice the following: revBuffer = 0x0012fe40 "100899ÌÌÌÌÌÌÌÌÌÌ998001" The relevant code is below. char buffer[5]; char revBuffer[5]; int i; int j=5; long number = 998001; itoa(number, buffer, 10); for(i=0; i<strlen(buffer);i++) { revBuffer[j] = buffer[i]; j--; } Any help would be great. TIA!

    Read the article

  • C code Error: free(): invalid next size (fast):

    - by user1436057
    I got an error from my code, but I'm not sure where to fix it. Here's the explanation of what my code does: I'm writing some code that will read an input file and store each line as an object (char type) in an array. The first line of the input file is a number. This number tells me how many lines that I should read and store in the array. Here's my code: int main(int argc, char *argv[]){ FILE *fp; char **path; int num, i; ... /*after reading the first line and store the number value in num*/ path = malloc(num *sizeof(char)); i=0; while (!feof(fp)) { char buffer[500]; int length = 0; for (ch = fgetc(fp); ch != EOF && ch != '\n'; ch = fgetc(fp)) { buffer[length++] = ch; } if(ch == '\n' && ch!= EOF){ buffer[length] = '\0'; path[i] = malloc(strlen(buffer)+1); strcpy(path[i], buffer); i++; } } ... free(path); } After running the code, I get this *** glibc detected *** free(): invalid next size (fast): I have searched around and know this is malloc/free error, but I don't exactly know to fix it. Any help would be great. Thanks!

    Read the article

  • How do I remove line references in generate output in doxygen?

    - by MeThinks
    I want to remove lines look as follows but I still want to return source code browsing Definition at line 377 of file xxx.h. I have tried the following two in the doxygen config file but these just remove cross references on types # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = NO update: I've just trying setting the following and seems to do the jobs but waiting to confirm if this is the correct way of achieving what I want SOURCE_BROWSER = NO

    Read the article

  • Read from socket

    - by Alberto
    I need to read from an AF_UNIX socket to a buffer using the function read from C, but I don't know the buffer size. I think the best way is to read N bytes until the read returns 0 (no more writers in the socket). Is this correct? Is there a way to guess the size of the buffer being written on the socket? I was thinking that a socket is a special file. Opening the file in binary mode and getting the size would help me in knowing the correct size to give to the buffer? I'm a very new to C, so please keep that in mind.

    Read the article

< Previous Page | 152 153 154 155 156 157 158 159 160 161 162 163  | Next Page >