Daily Archives

Articles indexed Friday March 19 2010

Page 9/124 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Why does my finite state machine take so long to execute?

    - by BillyONeal
    Hello all :) I'm working on a state machine which is supposed to extract function calls of the form /* I am a comment */ //I am a comment perf("this.is.a.string.which\"can have QUOTES\"", 123456); where the extracted data would be perf("this.is.a.string.which\"can have QUOTES\"", 123456); from a file. Currently, to process a 41kb file, this process is taking close to a minute and a half. Is there something I'm seriously misunderstanding here about this finite state machine? #include <boost/algorithm/string.hpp> std::vector<std::string> Foo() { std::string fileData; //Fill filedata with the contents of a file std::vector<std::string> results; std::string::iterator begin = fileData.begin(); std::string::iterator end = fileData.end(); std::string::iterator stateZeroFoundLocation = fileData.begin(); std::size_t state = 0; for(; begin < end; begin++) { switch (state) { case 0: if (boost::starts_with(boost::make_iterator_range(begin, end), "pref(")) { stateZeroFoundLocation = begin; begin += 4; state = 2; } else if (*begin == '/') state = 1; break; case 1: state = 0; switch (*begin) { case '*': begin = boost::find_first(boost::make_iterator_range(begin, end), "*/").end(); break; case '/': begin = std::find(begin, end, L'\n'); } break; case 2: if (*begin == '"') state = 3; break; case 3: switch(*begin) { case '\\': state = 4; break; case '"': state = 5; } break; case 4: state = 3; break; case 5: if (*begin == ',') state = 6; break; case 6: if (*begin != ' ') state = 7; break; case 7: switch(*begin) { case '"': state = 8; break; default: state = 10; break; } break; case 8: switch(*begin) { case '\\': state = 9; break; case '"': state = 10; } break; case 9: state = 8; break; case 10: if (*begin == ')') state = 11; break; case 11: if (*begin == ';') state = 12; break; case 12: state = 0; results.push_back(std::string(stateZeroFoundLocation, begin)); }; } return results; } Billy3

    Read the article

  • AudioQueueOfflineRender returning empty data

    - by hyn
    I'm having problems using AudioQueueOfflineRender to decode AAC data. When I examine the buffer after the call, it is always filled with empty data. I made sure the input buffer is valid and packet descriptions are provided. I searched and found that a few others have had the same problem: http://lists.apple.com/archives/Coreaudio-api/2008/Jul/msg00119.html Also, the inTimestamp argument doesn't make sense to me. Why should the renderer care where in the audio the beginning of the buffer corresponds to? The function throws an error if I pass in NULL, so I pass in the timestamp anyway.

    Read the article

  • close window in Tkinter message box

    - by rejinacm
    Hello, link text How to handle the "End Now" error in the below code: import Tkinter from Tkconstants import * import tkMessageBox tk = Tkinter.Tk() class MyApp: def __init__(self,parent): self.myparent = parent self.frame = Tkinter.Frame(tk,relief=RIDGE,borderwidth=2) self.frame.pack() self.message = Tkinter.Message(tk,text="Symbol Disolay") label=Tkinter.Label(self.frame,text="Is Symbol Displayed") label.pack() self.button1=Tkinter.Button(self.frame,text="YES") self.button1.pack(side=BOTTOM) self.button1.bind("<Button-1>", self.button1Click) self.button2=Tkinter.Button(self.frame,text="NO") self.button2.pack() self.button2.bind("<Button-1>", self.button2Click) self.myparent.protocol("WM_DELETE_WINDOW", self.handler) def button1Click(self, event): print "pressed yes" def button2Click(self, event): print "pressed no" def handler(self): if tkMessageBox.askokcancel("Quit?", "Are you sure you want to quit?"): self.myparent.quit() myapp = MyApp(tk) tk.mainloop()

    Read the article

  • How to user Hibernate @Valid constraint with Spring 3.x?

    - by Burak Dede
    I am working on simple form to validate fields like this one. public class Contact { @NotNull @Max(64) @Size(max=64) private String name; @NotNull @Email @Size(min=4) private String mail; @NotNull @Size(max=300) private String text; } I provide getter and setters hibernate dependencies on my classpath also.But i still do not get the how to validate simple form there is actually not so much documentation for spring hibernate combination. @RequestMapping(value = "/contact", method = RequestMethod.POST) public String add(@Valid Contact contact, BindingResult result) { .... } Could you explain it or give some tutorial , except original spring 3.x documentation

    Read the article

  • How to reverse items in WPF Datagrid?

    - by irf1x
    If i have DataGrid which looks like: Col 1 Col 2 ------- ------- 1 a 2 b 3 c ... ... n n Can the order be reversed easily without sorting? So that n is first, and 1 is last. I have custom sort implemented from this article, but sorting the same column twice in a row calls sorting function twice (which is slow), so just reversing the order should be faster and have the same effect.

    Read the article

  • How to speed up the reading of innerHTML in IE8?

    - by Dennis Cheung
    I am using JQuery with the DataTable plugin, and now I have a big performnce issue on the following line. aLocalData[jInner] = nTds[j].innerHTML; // jquery.dataTables.js:2220 I have a ajax call, and result string in HTML format. I convert them into HTML nodes, and that part is ok. var $result = $('<div/>').html(result).find("*:first"); // simlar to $result=$(result) but much more faster in Fx Then I activate enable the result from a plain table to a sortable datatable. The speed is acceptable in Fx (around 4sec for 900 rows), but unacceptable in IE8 (more then 100 seconds). I check it deep using the buildin profiler, and found the above single line take all 99.9% of the time, how can I speed it up? anything I missed? nTrs = oSettings.nTable.getElementsByTagName('tbody')[0].childNodes; for ( i=0, iLen=nTrs.length ; i<iLen ; i++ ) { if ( nTrs[i].nodeName == "TR" ) { iThisIndex = oSettings.aoData.length; oSettings.aoData.push( { "nTr": nTrs[i], "_iId": oSettings.iNextId++, "_aData": [], "_anHidden": [], "_sRowStripe": '' } ); oSettings.aiDisplayMaster.push( iThisIndex ); aLocalData = oSettings.aoData[iThisIndex]._aData; nTds = nTrs[i].childNodes; jInner = 0; for ( j=0, jLen=nTds.length ; j<jLen ; j++ ) { if ( nTds[j].nodeName == "TD" ) { aLocalData[jInner] = nTds[j].innerHTML; // jquery.dataTables.js:2220 jInner++; } } } }

    Read the article

  • vb6: set SysTabControl32 by code

    - by Fuxi
    hi, i'm coding a little app for controlling soulseek - what i want do is clicking the "Search Files" button by code. i've got the handle to the tabbed control (SysTabControl32) and managed to change the tab with following code: rc1 = SendMessage(hwnd, TCM_SETCURFOCUS, ByVal 0, ByVal 0&) the problem: the tab control is changing to the proper button, but nothing happens. i assume i also also have to send a mouseclick to it, as when clicking by mouse, the button goes down and up again. any ideas how to do this? thx

    Read the article

  • Combined states, FSM

    - by bobobobo
    Not sure this is the right place to ask, but is it "correct" to combine states of an FSM? Say you have an object with enum State { State1 = 1 << 0, State2 = 1 << 1, State3 = 1 << 2 } ; It just so happens that it makes sense to combine states, as in State myState = State1 | State2 ; however in FSM theory is this illegal?

    Read the article

  • How do I test OpenCL on GPU when logged in remotely on Mac?

    - by Christopher Bruns
    My OpenCL program can find the GPU device when I am logged in at the console, but not when I am logged in remotely with ssh. Further, if I run the program as root in the ssh session, the program can find the GPU. The computer is a Snow Leopard Mac with a GeForce 9400 GPU. If I run the program (see below) from the console or as root, the output is as follows (notice the "GeForce 9400" line): 2 devices found Device #0 name = GeForce 9400 Device #1 name = Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz but if it is just me, over ssh, there is no GeForce 9400 entry: 1 devices found Device #0 name = Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz I would like to test my code on the GPU without having to be root. Is that possible? Simplified GPU finding program below: #include <stdio.h> #include <OpenCL/opencl.h> int main(int argc, char** argv) { char dname[500]; size_t namesize; cl_device_id devices[10]; cl_uint num_devices; int d; clGetDeviceIDs(0, CL_DEVICE_TYPE_ALL, 10, devices, &num_devices); printf("%d devices found\n", num_devices); for (d = 0; d < num_devices; ++d) { clGetDeviceInfo(devices[d], CL_DEVICE_NAME, 500, dname, &namesize); printf("Device #%d name = %s\n", d, dname); } return 0; } EDIT: I found essentially the same question being asked on nvidia's forums. Unfortunately, the only answer was of the form "this is the wrong forum".

    Read the article

  • How do we group in BIRT without wasting lines, and still only printing the group item on the first l

    - by paxdiablo
    When grouping in BIRT, we frequently want the grouping value to show up on the first line as follows: Group User Reputation ------ --------------- ---------- Admins Bill The Weasel 51,018 Mark Grovel 118,101 Users pax_my_bags 73,554 Jon Scoot **,***,*** <- overflow clueless 92,928 The normal way of acheiving this is to lay out the group in the designer as follws: +---------+--------+--------------+ Tbl Hdr | Group | User | Reputation | +---------+--------+--------------+ Grp Hdr | [Group] | | | +---------+--------+--------------+ Grp Dtl | | [User] | [Reputation] | +---------+--------+--------------+ Grp Ftr | | | | +---------+--------+--------------+ Tbl Ftr | | | | +---------+--------+--------------+ which, unfortunately, lays out the data in exactly that way, with the grouped value on a different line: Group User Reputation ------ --------------- ---------- Admins Bill The Weasel 51,018 Mark Grovel 118,101 Users pax_my_bags 73,554 Jon Scoot **,***,*** <- overflow clueless 92,928 This is particularly painful with data where there's lots of groups with only one user since we use twice as much space as needed. If we move the [Group] data item down to the Grp Dtl line, we get it printed for every line in the group. How, in BIRT, do we merge the two lines Grp Hdr and the first Grp Dtl?

    Read the article

  • Brilliant features of C++

    - by John
    (Following Features to remove from C++ and Desired features for C++, I thought why not complete the trio...) What C++ features would you not change? What features are elegantly and brilliantly implemented and still look better than other popular languages?

    Read the article

  • Win32 window capture with BitBlt not displaying border

    - by user292533
    I have written some c++ code to capture a window to a .bmp file. BITMAPFILEHEADER get_bitmap_file_header(int width, int height) { BITMAPFILEHEADER hdr; memset(&hdr, 0, sizeof(BITMAPFILEHEADER)); hdr.bfType = ((WORD) ('M' << 8) | 'B'); // is always "BM" hdr.bfSize = 0;//sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + (width * height * sizeof(int)); hdr.bfReserved1 = 0; hdr.bfReserved2 = 0; hdr.bfOffBits = (DWORD)(sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)); return hdr; } BITMAPINFO get_bitmap_info(int width, int height) { BITMAPINFO bmi; memset(&bmi.bmiHeader, 0, sizeof(BITMAPINFOHEADER)); //initialize bitmap header bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = width; bmi.bmiHeader.biHeight = height; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 4 * 8; bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biSizeImage = width * height * 4; return bmi; } void get_bitmap_from_window(HWND hWnd, int * imageBuff) { HDC hDC = GetWindowDC(hWnd); SIZE size = get_window_size(hWnd); HDC hMemDC = CreateCompatibleDC(hDC); RECT r; HBITMAP hBitmap = CreateCompatibleBitmap(hDC, size.cx, size.cy); HBITMAP hOld = (HBITMAP)SelectObject(hMemDC, hBitmap); BitBlt(hMemDC, 0, 0, size.cx, size.cy, hDC, 0, 0, SRCCOPY); //PrintWindow(hWnd, hMemDC, 0); BITMAPINFO bmi = get_bitmap_info(size.cx, size.cy); GetDIBits(hMemDC, hBitmap, 0, size.cy, imageBuff, &bmi, DIB_RGB_COLORS); SelectObject(hMemDC, hOld); DeleteDC(hMemDC); ReleaseDC(NULL, hDC); } void save_image(HWND hWnd, char * name) { int * buff; RECT r; SIZE size; GetWindowRect(hWnd, &r); size.cx = r.right-r.left; size.cy = r.bottom-r.top; buff = (int*)malloc(size.cx * size.cy * sizeof(int)); get_bitmap_from_window(hWnd, buff); BITMAPINFO bmi = get_bitmap_info(size.cx, size.cy); BITMAPFILEHEADER hdr = get_bitmap_file_header(size.cx, size.cy); FILE * fout = fopen(name, "w"); fwrite(&hdr, 1, sizeof(BITMAPFILEHEADER), fout); fwrite(&bmi.bmiHeader, 1, sizeof(BITMAPINFOHEADER), fout); fwrite(buff, 1, size.cx * size.cy * sizeof(int), fout); fflush(fout); fclose(fout); free(buff); } It works find under XP, but under Vista the border of the window is transparent. Using PrintWindow solves the problem, but is unacceptable for performance reasons. Is there a performant code change, or a setting that can be changed to make the border non-transparent?

    Read the article

  • Difference between Popup's IsOpen and Visibility properties?

    - by cfouche
    I've played around with the WPF Popup Control and as far as I can see, the Visibility property is superfluous. If you have a Popup with IsOpen = True, it will be visible even if its Visibility = Collapsed. If you have a Popup with IsOpen = False, then its Visibility will be Collapsed, and will remain "Collapsed" when IsOpen changes to true, and it will appear. (i.e. you'll have something that appears on your screen, even though Snoop says it is Collapsed.) Why does the Popup control have both these properties? Am I missing something here?

    Read the article

  • How can I play compressed sound files in C# in a portable way?

    - by skolima
    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]

    Read the article

  • Questions every good Java/J2EE Developer should be able to answer?

    - by Rachel
    I was going through Questions every good .Net developer should be able to answer and was highly impressed with the content and approach of this question, and so in the same spirit, I am asking this question for Java/J2EE Developer. What questions do you think should a good Java/J2EE programmer be able to answer? I am marking this question as community wiki as it is not user specific and it aims to serve programming community at large. Looking forward for some amazing responses. EDIT: Please answer questions too, as suggested in the comments, so that people could learn something new regarding the language, too.

    Read the article

  • How to write image of a floppy disk to a flash drive?

    - by Usman Ajmal
    I have created an image of a floppy disk by executing: dd if=/dev/fd0 of=/home/myFloppy.img My floppy disk is no more working now. So I am thinking now if it's possible to write the image of that floppy to a flash drive and then i may boot my machine from the flash drive. My machine's BIOS has the option of 'Boot from USB'.

    Read the article

  • With modern PC systems, what less-than-optimal designs have we inherited?

    - by Rob Kam
    What have been less than optimal design choices, that are now (almost) immutable features of the modern PC system, and what constraints led to these choices? There have been a great many of these. For example the qwerty keyboard is widespread although the Dvorak keyboard might be a better choice. I guess this is something to do with the teletypes that were used as early computer keyboards, which had originally been modified from typewriters.

    Read the article

  • Communication between java server and matlab client

    - by user272587
    I'd like to establish a server(Java)/client (Matlab) communication using socket. They can send messages to each other. An example shows how to do this in Java server and Java client, http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html. When I try to rewrite the client part in Matlab, I only can get the first message that the Java server sends and display it in the Matlab command window. When I type a message in the Matlab command window, I can't pass it to the Java Server. Jave code: kkSocket = new Socket("localhost", 3434); Matlab equivalent: kkSocket = Socket('localhost', 3434); Java code for client: out = new PrintWriter(kkSocket.getOutputStream(), true); in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream())); What would be a Matlab equivalent for this? Thanks in advance.

    Read the article

  • Legacy application with JDBC and JNDI REALM authentication

    - by KB
    Hello All, My application currently relies on JDBC realm authentication. Recent needs have forced us to think about having LDAP authentication as well. We are thinking about using Active Directory for both authentication as well as authorization (roles). As a standalone test, I was able to authenticate my application with AD. But here is the confusion I have going forward. If the user chooses LDAP authentication when he logs in, I authenticate the user with AD, get the user's roles and do I replicate(create a new) windows user in my database?. I have to have the user in the database, because many parts of the application is designed to retrieve the user from database If the users chooses local login, I still should have JDBCRealm somewhere that I should use to authenticate the user. Is it possible to have multiple realms in tomcat? (I sort of know it is possible, but havent seen much documentation around it) Any thoughts, comments, suggestions would immensely help me Thanks K

    Read the article

  • Guide to Learn J2ME

    - by Sopolin
    Hi all, I am starting study java2me. But I have some source study about it like ebook, source sample code, and ... Could anybody give some link website or source ebook study about it. Thanks, Sopolin

    Read the article

  • Caliburn and prism samples

    - by Simon
    Are there any sample applications avaliable that make use of both caliburn and prism? I know there are blogs that talk about it but I would like to wade into some code and see how it all fits together. http://caliburn.codeplex.com http://compositewpf.codeplex.com/

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >