Search Results

Search found 1156 results on 47 pages for 'roman'.

Page 19/47 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Is it a solvable problem to generate a regular expression that matches some input set?

    - by Roman
    I provide some input set which contains known separated number of text blocks. I want to make a program that automatically generate 1 or more regular expressions each of which matches every text block in the input set. I see some relatively easy ways to implement a brute-force search. But I'm not an expert in compilers theory. That's why I'm curious: 1) is this problem solvable? or there are some principle impossibility to make such algorithm? 2) is it possible to achieve polynomial complexity for this algorithm and avoid brute forcing?

    Read the article

  • Can Bonjour browse a service with a particular name?

    - by Roman
    Bonjour provides "DNSSD.browse(serviceType,callBackObject)" method which browses for services of a particular type. If a service of the given type is found, Bonjour call "callBackObject.serviceFound". If the service is lost, Bonjour calls "callBackObject.serviceLost". I alway considered "DNSSD.browse" as a method for monitoring a particular service. Bonjour monitors a particular service and calls necessary method if the service is found (available) or lost (not available). But than I realized that "DNSSD.browse" receives (as argument) a type of service (for example "http.tcp") and there can be several services of this type. So, its probably calls "serviceFound" and "serviceLost" if any service of the specified type is found or lost, respectively. But in my application I would like to browse just for one particular service. What is the best way to do it? I have two potential solutions: When I register a service, I give it a unique type. For example: "server1.http.tcp". I register services with unique names (not types) and ask Bonjour to browse for services with particular names. But I am not sure that Bonjour provide such possibility. Can it browse for services with specific names?

    Read the article

  • Different standard streams per POSIX thread

    - by Roman Nikitchenko
    Is there any possibility to achieve different redirections for standard output like printf(3) for different POSIX thread? What about standard input? I have lot of code based on standard input/output and I only can separate this code into different POSIX thread, not process. Linux operation system, C standard library. I know I can refactor code to replace printf() to fprintf() and further in this style. But in this case I need to provide some kind of context which old code doesn't have. So doesn't anybody have better idea (look into code below)? #include <pthread.h> #include <stdio.h> void* different_thread(void*) { // Something to redirect standard output which doesn't affect main thread. // ... // printf() shall go to different stream. printf("subthread test\n"); return NULL; } int main() { pthread_t id; pthread_create(&id, NULL, different_thread, NULL); // In main thread things should be printed normally... printf("main thread test\n"); pthread_join(id, NULL); return 0; }

    Read the article

  • How can I remove a JPanel from a JFrame?

    - by Roman
    Recently I asked here how to add a new JPanel to JFrame. The answer helped me to get a working code. But not I have a related question: "How can I remove an old JPanel". I need that because of the following problem. A new JPanel appears appears when I want (either time limit is exceeded or user press the "Submit" button). But in several seconds some element of the old JPanel appears together with the component of the new JPanel. I do not understand why it happens. I thought that it is because I have to other threads which update the window. But the first thread just add the old panel once (so, it should be finished). And in the second thread I have a loop which is broken (so, it also should be finished). Here is my code: private Thread controller = new Thread() { public void run() { // First we set the initial pane (for the selection of partner). SwingUtilities.invokeLater(new Runnable() { public void run() { frame.getContentPane().add(generatePartnerSelectionPanel()); frame.invalidate(); frame.validate(); } }); // Update the pane for the selection of the parnter. for (int i=40; i>0; i=i-1) { final int sec = i; SwingUtilities.invokeLater(new Runnable() { public void run() { timeLeftLabel.setText(sec + " seconds left."); } }); try {Thread.sleep(1000);} catch (InterruptedException e) {} if (partnerSubmitted) {break;} } // For the given user the selection phase is finished (either the time is over or form was submitted). SwingUtilities.invokeLater(new Runnable() { public void run() { frame.getContentPane().add(generateWaitForGamePanel()); frame.invalidate(); frame.validate(); } }); } };

    Read the article

  • Why it's not "if" and not "else"?

    - by Roman
    I have this code: $link = mysql_connect("localhost", "ctmanager", "pswsafgcsadfgG"); if ( ! $link ) die("I cannot connect to MySQL.<br>\n"); else print "Connection is established.<br>\n"; print "a"; if ( mysql_create_db("ct", $link) ) print "AAA"; else print "BBB"; print "2"; die(); And this is the output: Connection is established. a So, I cannot understand how it's possible that neither "AAA" no "BBB" is outputted. Is it because program dies at mysql_create_db?

    Read the article

  • Can I find out which thread is running using Eclipse?

    - by Roman
    I close my application by pressing a "Close" button. But in the Eclipse I see a red square indicating that something is still running. When I press this red square, I kill my application completely. Is it possible to find out what is still running (which method, which loop) using Eclipse? P.S. I am a newbie. So, it would be nice to have a simple solution. I also might not understand your answer if you use "technical" words which I do not know.

    Read the article

  • How do I create a class repository in Java and do I really need it?

    - by Roman
    I have a large number of objects which are identified by names (strings). So, I would like to have a kind of mapping from object name to the class instances. I was told that in this situation I can use a "repository" class which works like that: Server myServer = ServerRepository.getServer("NameOfServer"); So, if there is already an object (sever) with the "NameOfServer" it will be returned by the "getServer". If such an object does not exist yet, it will be created and returned by the "getServer". So, my question is how to program such a "repository" class? In this class I have to be able to check if there is an instance of a given class such that it has a given value of a given field. How can I do it? I need to have a kind of loop over all existing object of a given class? Another part of my question is why I cannot use associative arrays (associative container, map, mapping, dictionary, finite map)? (I am not sure how do you call it in Java) In more details, I have an "array" which maps names of objects to objects. So, whenever I create a new object, I add a new element to the array: myArray["NameOfServer"] = new Server("NameOfServer").

    Read the article

  • For what purpose does java have a float primitive type?

    - by Roman
    I heard plenty times different claims about float type in java. The most popular issues typicaly regard to converting float value to double and vice versa. I read (rather long time ago and not sure that it's actual now with new JVM) that float gives much worse performance then double. And it's also not recommended to use float in scientific applications which should have certain accuracy. I also remember that when I worked with AWT and Swing I had some problems with using float or double (like using Point2D.Float or Point2D.Double). So, I see only 2 advantages of float over double: it needs only 4 bytes while double needs 8 bytes JMM garantees that assignment operation is atomic with float variables while it's not atomic with double's. Are there any other cases where float is better then double? Do you use float's in your applications? It seems to me that the only valuable reason java has float is backward compatibility.

    Read the article

  • How to set default values to all wrong or null parameters of method?

    - by Roman
    At the moment I have this code (and I don't like it): private RenderedImage private RenderedImage getChartImage (GanttChartModel model, String title, Integer width, Integer height, String xAxisLabel, String yAxisLabel, Boolean showLegend) { if (title == null) { title = ""; } if (xAxisLabel == null) { xAxisLabel = ""; } if (yAxisLabel == null) { yAxisLabel = ""; } if (showLegend == null) { showLegend = true; } if (width == null) { width = DEFAULT_WIDTH; } if (height == null) { height = DEFAULT_HEIGHT; } ... } How can I improve it? I have some thoughts about introducing an object which will contain all these parameters as fields and then, maybe, it'll be possible to apply builder pattern. But still don't have clear vision how to implement that and I'm not sure that it's worth to be done. Any other ideas?

    Read the article

  • cmake and parallel building with "make -jN"

    - by Roman D
    Hi all, I'm trying to setup a parallel CMake-based build for my source tree, but when I issue $ cmake . $ make -j2 I get a jobserver unavailable: using -j1. Add '+' to parent make rule warning. Does anyone have an idea if it is possible to fix it somehow?

    Read the article

  • Does importing of packages change visibility of classes?

    - by Roman
    I jsut learned that A class may be declared with the modifier public, in which case that class is visible to all classes everywhere. If a class has no modifier (the default, also known as package-private), it is visible only within its own package. This is a clear statement. But this information interfere with my understanding of importing of packages (which easily can be wrong). I thought that importing a package I make classes from the imported package visible to the importing class. So, how does it work? Are public classes visible to all classes everywhere under condition that the package containing the public class is imported? Or there is not such a condition? What about the package-private classes? They are invisible no mater if the containing package was imported or not? ADDED: It seems to me that I got 2 answers which are marked as good (up-voted) and which contradict eachother.

    Read the article

  • Opening vbp Visual Basic Project

    - by Roman
    I have got some old sources written in Visual Basic. There are *.bas, *.cls, *.frm and *.vbp files. As I understand, vbp is a project file. But I cannot open it with my Visual Studio 2008. What version of VS should I install to open *.vbp file? Google says it is Visual Studio 6, but I am not sure and I cannot find Visual Studio 6 for downloading. Is there any publicly available free edition of Visual Studio 6 with Visual Basic? Thanks.

    Read the article

  • Should I close sockets from both ends?

    - by Roman
    I have the following problem. My client program monitor for availability of server in the local network (using Bonjour, but it does not rally mater). As soon as a server is "noticed" by the client application, the client tries to create a socket: Socket(serverIP,serverPort);. At some point the client can loose the server (Bonjour says that server is not visible in the network anymore). So, the client decide to close the socket, because it is not valid anymore. At some moment the server appears again. So, the client tries to create a new socket associated with this server. But! The server can refuse to create this socket since it (server) has already a socket associated with the client IP and client port. It happens because the socket was closed by the client, not by the server. Can it happen? And if it is the case, how this problem can be solved? Well, I understand that it is unlikely that the client will try to connect to the server from the same port (client port), since client selects its ports randomly. But it still can happen (just by chance). Right?

    Read the article

  • What is the most effective way to create BigInteger instance from int value?

    - by Roman
    I have a method (in 3rd-party library) with BigInteger parameter: public void setValue (BigInteger value) { ... } I don't need 'all its power', I only need to work with integers. So, how can I pass integers to this method? My solution is to get string value from int value and then create BigInteger from string: int i = 123; setValue (new BigInteger ("" + i)); Are there any other (recommended) ways to do that?

    Read the article

  • Guice expert question

    - by Roman
    Hi All I am wondering if someone would be such an expert in guice that he even would know how to implement that : I have an injection annotation (@ConfParam)with some parameters , like that : class TestClass { private final int intValue; @Inject public TestClass(@ConfParam(section = "test1", key = "1") int intValue{ this.intValue = intValue; } public int getIntValue() { return intValue; } } The ConfParam is my custom annotation. Now , when the injection value is requested , I would like guice to create a dynamic binding, to resolve the value. For that binding I will need the parameters inside the annotation. Some example could be , I will have to look in the database in some table where the section is ? and the key is ?. All the trouble is that the data is not available when the injector is created and could be also be added at runtime. Ps. I static solution is easy. ( just have a look at the Names class)

    Read the article

  • Can I create my own database from PHP?

    - by Roman
    I have a working PHP server. Now I want to use databases (MySQL or something similar). Is it possible to create a database from PHP? I would like to emphasize that in my case I do not have any user-name and password to which I can use to connect to MySQL server. I also do not have a control-panel where I could create a database or a table in an existing database.

    Read the article

  • Why do encodeXxx methods in UIComponent accept FacesContext parameter?

    - by Roman
    I haven't ever before created custom components in JSF so I've noticed only now that methods like encodeBegin(), encodeEnd() etc accept FacesContext parameter. FacesContext instance can usually be received with FacesContext.getCurrentInstance(). So, I wonder whether these methods have FacesContext parameter just for convenience or some different objects can be passed there (maybe from external resources..). If the latter is possible then could you give an example pls.

    Read the article

  • Append to a file in Java. Is it a joke?

    - by Roman
    I need to append some data to existing file. I started to browse Internet to find out how to do it. And I found this mini (as they say) application to do that: http://www.devdaily.com/java/edu/qanda/pjqa00009.shtml Well I was already annoyed by the fact how complicated are things in Java (in comparison with Python, for example). But this is too much! I just want to add to a file! It should be one line! Not 50! Or do I get something wrong?

    Read the article

  • Syntax for documenting JSON structure

    - by Roman A. Taycher
    So I'm trying to document the format of the json returned by an api I am writing against and I'd like to know if there is any popular format for the documentation of json structure. Note I'm not trying to to test or validate anything, I'm just using this for documentation. Also some ways to add comments to non-constants(items always returned w/ the same value) would be nice. This the not totally thought out scheme I'm currently using: Plain names refer to identifiers or types. Some types have type-comment Strings that appear to be constant(always returned for that type of request) strings are "str" Constant Numbers would be just the number Constant null is null Booleans are true/false for constant booleans or Boolean otherwise [a,b,c] are lists with 3 items a,b,c [... ...] is a list of repeating elements of some types/constants/patterns {a:A,b:B,c:c} and {... ...} is the same for a dictionary. example: story := [header,footer] header := {"data":realHeader,"kind":"Listing"} realHeader := {"after": null, "before": null, "children": [{"data": realRealHeader, "kind": "t3"}], "modhash": ""} footer := {"data":AlmostComments,"kind":"Listing"} AlmostComments := {"data": {"after": null, "before": null, "children": comments, "modhash": ""}, "kind": "t1"} comments := [...{"data":comment, "kind":"t1"}...] realRealHeader := {"author": string, "clicked": boolean, "created": int, "created_utc": int, "domain": "code.reddit.com", "downs": int, "hidden": boolean, "id": string-id, "is_self": boolean, "levenshtein": null, "likes": null, "media": null, "media_embed": { }, "name": string-id, "num_comments": int, "over_18": false, "permalink": string-urlLinkToStoryStartingFrom/r, "saved": false, "score": int, "selftext": string, "selftext_html": string-html, "subreddit": string-subredditname, "subreddit_id": string-id, "thumbnail": "", "title": string, "ups": int, "url": "http://code.reddit.com/" } comments := { "author": string, "body": string-body_html-wout-html, "body_html": string-html-formated, "created": int, "created_utc": int, "downs": int, "id": string-id, "levenshtein": null, "likes": null, "link_id": string-id, "name": string-id", "parent_id": string-id, "replies": AlmostComments or null, "subreddit": string-subredditname, "subreddit_id": string-id, "ups": int }

    Read the article

  • Displaying "broken" sprites?

    - by Roman
    I'm quite new to the world of 2D-Engines. I figured out how to load images and display those as sprites and stuff, but theres one question that bugs me. For instance, when a "rocket" hits an object it will deal damage to it and leave a crater behind. I'd like to have the crater shown on that object. That would require "skipping" some of the pixels of that image when rendering, doesn't it? My question is, how would you do such a thing? What data strcture would you use to save this? How to display a "broken" sprite?

    Read the article

  • Why Eclipse does not see .jar file of a library?

    - by Roman
    I have a java project in which I have "Referenced Libraries". In the "Referenced Libraries" I have a .jar file of a library that I use (I use only one external library). When I try to "Run - Run" the code I have a NullPointerException. From my previous experience I know that it it (very likely) because my code does not see the library. I just started to use Eclipse and it can be the I do not "connect" libraries in a correct way. Should I use some options or additional action to force Eclipse to see the .jar file of the library? ADDED: By the right click on the library I get a drop-down menu in which I see "Build Path". My be I need to do something there?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >